Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fix the `loop` variable being undefined when used in the sequence of a nested `for` tag
* Reject a deprecated `Template` instance created by another environment in `Environment::resolveTemplate()`
* Fix a compilation error inside an `autoescape` tag leaking its escaping strategy into the next compiled template
* Fix `FilesystemLoader` template names depending on the slash style used to load a template first
* Fix the non-selected branch of a `guard` tag registering its parent, blocks, and macros
* Speed up reading object attributes backed by getters or class constants
* Fix the sandbox not reporting the line of a rejected `guard` tag
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/FilesystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function getSourceContext(string $name): Source
return new Source('', $name, '');
}

return new Source(file_get_contents($path), $name, $path);
return new Source(file_get_contents($path), $this->normalizeName($name), $path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't see that there was already a normalize function. Let me try this.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to copy the private normalizeName() function in my custom FilesystemLoader class, but it works.

}

public function getCacheKey(string $name): string
Expand Down
6 changes: 6 additions & 0 deletions tests/Loader/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public function testGetSourceContext(): void
$this->assertEquals(realpath($path.'/errors/index.html'), realpath($loader->getSourceContext('errors/index.html')->getPath()));
}

public function testGetSourceContextNormalizesName(): void
{
$loader = new FilesystemLoader([__DIR__.'/../Fixtures']);
$this->assertSame('errors/index.html', $loader->getSourceContext('errors\index.html')->getName());
}

/**
* @dataProvider getSecurityTests
*/
Expand Down