protected function Twig_Loader_Filesystem::validateName

1 call to Twig_Loader_Filesystem::validateName()
Twig_Loader_Filesystem::findTemplate in drupal/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php

File

drupal/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php, line 132

Class

Twig_Loader_Filesystem
Loads template from the filesystem.

Code

protected function validateName($name) {
  if (false !== strpos($name, "\0")) {
    throw new Twig_Error_Loader('A template name cannot contain NUL bytes.');
  }
  $parts = explode('/', $name);
  $level = 0;
  foreach ($parts as $part) {
    if ('..' === $part) {
      --$level;
    }
    elseif ('.' !== $part) {
      ++$level;
    }
    if ($level < 0) {
      throw new Twig_Error_Loader(sprintf('Looks like you try to load a template outside configured directories (%s).', $name));
    }
  }
}