Skip to content

[Routing] Fixed XML options resolution #30507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2019
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
3 changes: 2 additions & 1 deletion src/Symfony/Component/Routing/Loader/XmlFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private function parseConfigs(\DOMElement $node, $path)
$options = [];
$condition = null;

/** @var \DOMElement $n */
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
if ($node !== $n->parentNode) {
continue;
Expand All @@ -226,7 +227,7 @@ private function parseConfigs(\DOMElement $node, $path)
$requirements[$n->getAttribute('key')] = trim($n->textContent);
break;
case 'option':
$options[$n->getAttribute('key')] = trim($n->textContent);
$options[$n->getAttribute('key')] = XmlUtils::phpize(trim($n->textContent));
break;
case 'condition':
$condition = trim($n->textContent);
Expand Down
13 changes: 13 additions & 0 deletions src/Symfony/Component/Routing/Tests/Fixtures/localized/utf8.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="app_utf8" path="/utf8">
<option key="utf8">true</option>
</route>
<route id="app_no_utf8" path="/no-utf8">
<option key="utf8">false</option>
</route>
</routes>
20 changes: 20 additions & 0 deletions src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ public function testLoadWithImport()
}
}

public function testUtf8Route()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routeCollection = $loader->load('utf8.xml');
$routes = $routeCollection->all();

$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);

$utf8Route = $routeCollection->get('app_utf8');

$this->assertSame('/utf8', $utf8Route->getPath());
$this->assertTrue($utf8Route->getOption('utf8'), 'Must be utf8');

$noUtf8Route = $routeCollection->get('app_no_utf8');

$this->assertSame('/no-utf8', $noUtf8Route->getPath());
$this->assertFalse($noUtf8Route->getOption('utf8'), 'Must not be utf8');
}

/**
* @expectedException \InvalidArgumentException
* @dataProvider getPathsToInvalidFiles
Expand Down
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