Skip to content

Commit 00c775e

Browse files
committed
bug #34915 [FrameworkBundle] Fix invalid Windows path normalization in TemplateNameParser (mvorisek)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle] Fix invalid Windows path normalization in TemplateNameParser | Q | A | ------------- | --- | Branch? | 3.4 - <5.0 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | no | License | MIT | Doc PR | Fix invalid Windows path normalization All versions of Symfony until 5.0 (which does no longer do extra file path normalization) normalize Windows paths wrongly. See PrestaShop/PrestaShop#16736 and https://bugs.php.net/bug.php?id=78939 Currently this issue can be observed when Symfony is run by NTS PHP only, but once the PHP issue will be fixed, this issue will probably affects all Windows users when absolute template name is passed to Symfony templating. Commits ------- 130df8c Fix invalid Windows path normalization
2 parents 2ecdc3a + 130df8c commit 00c775e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function parse($name)
4444
}
4545

4646
// normalize name
47-
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name)));
47+
$name = preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name));
4848

4949
if (false !== strpos($name, '..')) {
5050
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public function provideAbsolutePaths()
9898
{
9999
return [
100100
['/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')],
101-
['C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')],
102-
['C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')],
101+
['C:\\path\\to\\section\\name.html.php', 'C:/path/to/section/name.html.php', 'C:/path/to/section/name.html.php', new BaseTemplateReference('C:/path/to/section/name.html.php', 'php')],
102+
['C:\\path\\to\\section\\name:foo.html.php', 'C:/path/to/section/name:foo.html.php', 'C:/path/to/section/name:foo.html.php', new BaseTemplateReference('C:/path/to/section/name:foo.html.php', 'php')],
103103
['\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')],
104104
['/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')],
105105
];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy