protected function Twig_Loader_Filesystem::validateName in Translation template extractor 7.3
Same name and namespace in other branches
- 6.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 239
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));
}
}
}