You are here

protected function Twig_Loader_Filesystem::validateName in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/Loader/Filesystem.php \Twig_Loader_Filesystem::validateName()
1 call to Twig_Loader_Filesystem::validateName()
Twig_Loader_Filesystem::findTemplate in vendor/Twig/Loader/Filesystem.php

File

vendor/Twig/Loader/Filesystem.php, line 215

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.');
  }
  $name = ltrim($name, '/');
  $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));
    }
  }
}