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

Appearance settings

Commit 64d8c99

Browse filesBrowse files
author
Jules Pietri
committed
[Routing] Fixed XML options resolution
1 parent b43cfc8 commit 64d8c99
Copy full SHA for 64d8c99

File tree

3 files changed

+35
-1
lines changed
Filter options

3 files changed

+35
-1
lines changed

‎src/Symfony/Component/Routing/Loader/XmlFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/XmlFileLoader.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ private function parseConfigs(\DOMElement $node, $path)
208208
$options = [];
209209
$condition = null;
210210

211+
/** @var \DOMElement $n */
211212
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
212213
if ($node !== $n->parentNode) {
213214
continue;
@@ -226,7 +227,7 @@ private function parseConfigs(\DOMElement $node, $path)
226227
$requirements[$n->getAttribute('key')] = trim($n->textContent);
227228
break;
228229
case 'option':
229-
$options[$n->getAttribute('key')] = trim($n->textContent);
230+
$options[$n->getAttribute('key')] = XmlUtils::phpize(trim($n->textContent));
230231
break;
231232
case 'condition':
232233
$condition = trim($n->textContent);
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<routes xmlns="http://symfony.com/schema/routing"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/routing
5+
http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<route id="app_utf8" path="/utf8">
8+
<option key="utf8">true</option>
9+
</route>
10+
<route id="app_no_utf8" path="/no-utf8">
11+
<option key="utf8">false</option>
12+
</route>
13+
</routes>

‎src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ public function testLoadWithImport()
8383
}
8484
}
8585

86+
public function testUtf8Route()
87+
{
88+
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
89+
$routeCollection = $loader->load('utf8.xml');
90+
$routes = $routeCollection->all();
91+
92+
$this->assertCount(2, $routes, 'One routes is loaded');
93+
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
94+
95+
$utf8Route = $routeCollection->get('app_utf8');
96+
97+
$this->assertSame('/utf8', $utf8Route->getPath());
98+
$this->assertTrue($utf8Route->getOption('utf8'), 'Must be utf8');
99+
100+
$noUtf8Route = $routeCollection->get('app_no_utf8');
101+
102+
$this->assertSame('/no-utf8', $noUtf8Route->getPath());
103+
$this->assertFalse($noUtf8Route->getOption('utf8'), 'Must not be utf8');
104+
}
105+
86106
/**
87107
* @expectedException \InvalidArgumentException
88108
* @dataProvider getPathsToInvalidFiles

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.