Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe1f5d2

Browse files
committed
[FrameworkBundle] Fix a regression in handling absolute and namespaced template paths
1 parentbaf35cf commitfe1f5d2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function parse($name)
5656
thrownew \RuntimeException(sprintf('Template name "%s" contains invalid characters.',$name));
5757
}
5858

59-
if (!preg_match('/^(?:([^:]*):)?(?:([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/',$name,$matches)) {
59+
if (!preg_match('/^(?:([^:]*):([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/',$name,$matches) ||$this->isAbsolute($name) ||0 ===strpos($name,'@')) {
6060
returnparent::parse($name);
6161
}
6262

@@ -72,4 +72,9 @@ public function parse($name)
7272

7373
return$this->cache[$name] =$template;
7474
}
75+
76+
privatefunctionisAbsolutePath($file)
77+
{
78+
return (bool)preg_match('#^(?:/|[a-zA-Z]:)#',$file);
79+
}
7580
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public function parseProvider()
6666
array('::index.html.php','::index.html.php','views/index.html.php',newTemplateReference('','','index','html','php')),
6767
array('index.html.php','::index.html.php','views/index.html.php',newTemplateReference('','','index','html','php')),
6868
array('FooBundle:Post:foo.bar.index.html.php','FooBundle:Post:foo.bar.index.html.php','@FooBundle/Resources/views/Post/foo.bar.index.html.php',newTemplateReference('FooBundle','Post','foo.bar.index','html','php')),
69+
array('@FooBundle/Resources/views/layout.html.twig','@FooBundle/Resources/views/layout.html.twig','@FooBundle/Resources/views/layout.html.twig',newBaseTemplateReference('@FooBundle/Resources/views/layout.html.twig','twig')),
70+
array('@FooBundle/Foo/layout.html.twig','@FooBundle/Foo/layout.html.twig','@FooBundle/Foo/layout.html.twig',newBaseTemplateReference('@FooBundle/Foo/layout.html.twig','twig')),
71+
array('/path/to/section/index.html.php','/path/to/section/index.html.php','/path/to/section/index.html.php',newBaseTemplateReference('/path/to/section/index.html.php','php')),
72+
array('C:\\path\\to\\section\\name.html.php','C:path/to/section/name.html.php','C:path/to/section/name.html.php',newBaseTemplateReference('C:path/to/section/name.html.php','php')),
73+
array('C:\\path\\to\\section\\name:foo.html.php','C:path/to/section/name:foo.html.php','C:path/to/section/name:foo.html.php',newBaseTemplateReference('C:path/to/section/name:foo.html.php','php')),
74+
array('\\path\\to\\section\\name.html.php','/path/to/section/name.html.php','/path/to/section/name.html.php',newBaseTemplateReference('/path/to/section/name.html.php','php')),
6975
array('/path/to/section/name.php','/path/to/section/name.php','/path/to/section/name.php',newBaseTemplateReference('/path/to/section/name.php','php')),
7076
array('name.twig','name.twig','name.twig',newBaseTemplateReference('name.twig','twig')),
7177
array('name','name','name',newBaseTemplateReference('name')),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp