Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f038da0

Browse files
committed
bug #30507 [Routing] Fixed XML options resolution (Jules Pietri)
This PR was merged into the 3.4 branch. Discussion ---------- [Routing] Fixed XML options resolution | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Found this bug while adding tests in #30501. I need it to be merged upward so it can get green there. Thanks! Commits ------- 53a6ff8 [Routing] Fixed XML options resolution
2 parents 0127b26 + 53a6ff8 commit f038da0

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

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

Lines 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);
Lines 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

Lines 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, 'Two routes are 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)