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 41ad9d8

Browse filesBrowse files
committed
[Routing] make xml loader more tolerant
schemes and methods may also be delimited by whitespace, comma or pipe. this eases migration as now schemes="GET|POST" also works
1 parent 49984b6 commit 41ad9d8
Copy full SHA for 41ad9d8

File tree

Expand file treeCollapse file tree

2 files changed

+8
-18
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-18
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/XmlFileLoader.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $p
126126
$node->removeAttribute('pattern');
127127
}
128128

129-
$schemes = array_filter(explode(' ', $node->getAttribute('schemes')));
130-
$methods = array_filter(explode(' ', $node->getAttribute('methods')));
129+
$schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY);
130+
$methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY);
131131

132132
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
133133

@@ -154,8 +154,8 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
154154
$type = $node->getAttribute('type');
155155
$prefix = $node->getAttribute('prefix');
156156
$host = $node->hasAttribute('host') ? $node->getAttribute('host') : null;
157-
$schemes = $node->hasAttribute('schemes') ? array_filter(explode(' ', $node->getAttribute('schemes'))) : null;
158-
$methods = $node->hasAttribute('methods') ? array_filter(explode(' ', $node->getAttribute('methods'))) : null;
157+
$schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null;
158+
$methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null;
159159

160160
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
161161

‎src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd
+4-14Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@
1717

1818
<xsd:element name="routes" type="routes" />
1919

20-
<xsd:simpleType name="word">
21-
<xsd:restriction base="xsd:string">
22-
<xsd:pattern value="([a-zA-Z]){3,}"/>
23-
</xsd:restriction>
24-
</xsd:simpleType>
25-
26-
<xsd:simpleType name="stringlist">
27-
<xsd:list itemType="word"/>
28-
</xsd:simpleType>
29-
3020
<xsd:complexType name="routes">
3121
<xsd:choice minOccurs="0" maxOccurs="unbounded">
3222
<xsd:element name="import" type="import" />
@@ -49,8 +39,8 @@
4939
<xsd:attribute name="path" type="xsd:string" />
5040
<xsd:attribute name="pattern" type="xsd:string" />
5141
<xsd:attribute name="host" type="xsd:string" />
52-
<xsd:attribute name="schemes" type="stringlist" />
53-
<xsd:attribute name="methods" type="stringlist" />
42+
<xsd:attribute name="schemes" type="xsd:string" />
43+
<xsd:attribute name="methods" type="xsd:string" />
5444
</xsd:complexType>
5545

5646
<xsd:complexType name="import">
@@ -60,8 +50,8 @@
6050
<xsd:attribute name="type" type="xsd:string" />
6151
<xsd:attribute name="prefix" type="xsd:string" />
6252
<xsd:attribute name="host" type="xsd:string" />
63-
<xsd:attribute name="schemes" type="stringlist" />
64-
<xsd:attribute name="methods" type="stringlist" />
53+
<xsd:attribute name="schemes" type="xsd:string" />
54+
<xsd:attribute name="methods" type="xsd:string" />
6555
</xsd:complexType>
6656

6757
<xsd:complexType name="element">

0 commit comments

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