Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FilesystemLoader.php

function FilesystemLoader::validateName

1 call to FilesystemLoader::validateName()
FilesystemLoader::findTemplate in vendor/twig/twig/src/Loader/FilesystemLoader.php

File

vendor/twig/twig/src/Loader/FilesystemLoader.php, line 258

Class

FilesystemLoader
Loads template from the filesystem.

Namespace

Twig\Loader

Code

private function validateName(string $name) : void {
    if (str_contains($name, "\x00")) {
        throw new LoaderError('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 LoaderError(\sprintf('Looks like you try to load a template outside configured directories (%s).', $name));
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal