8000 Merge branch '2.7' into 2.8 · symfony/symfony@c337bf6 · GitHub
[go: up one dir, main page]

Skip to content

Commit c337bf6

Browse files
Merge branch '2.7' into 2.8
* 2.7: Use the PCRE_DOLLAR_ENDONLY modifier in route regexes
2 parents 8ecf01b + 478fbdc commit c337bf6

19 files changed

+174
-153
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\DependencyInjection\Reference;
1919
use Symfony\Component\EventDispatcher\EventDispatcher;
2020
use Symfony\Component\Routing\Route;
21+
use Symfony\Component\Routing\CompiledRoute;
2122
use Symfony\Component\Routing\RouteCollection;
2223

2324
class ObjectsProvider
@@ -35,7 +36,7 @@ public static function getRouteCollections()
3536
public static function getRoutes()
3637
{
3738
return array(
38-
'route_1' => new Route(
39+
'route_1' => new RouteStub(
3940
'/hello/{name}',
4041
array('name' => 'Joseph'),
4142
array('name' => '[a-z]+'),
@@ -44,7 +45,7 @@ public static function getRoutes()
4445
array('http', 'https'),
4546
array('get', 'head')
4647
),
47-
'route_2' => new Route(
48+
'route_2' => new RouteStub(
4849
'/name/add',
4950
array(),
5051
array(),
@@ -207,3 +208,11 @@ public static function staticMethod()
207208
{
208209
}
209210
}
211+
212+
class RouteStub extends Route
213+
{
214+
public function compile()
215+
{
216+
return new CompiledRoute('', '#PATH_REGEX#', array(), array(), '#HOST_REGEX#');
217+
}
218+
}

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"path": "\/hello\/{name}",
3-
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s",
3+
"pathRegex": "#PATH_REGEX#",
44
"host": "localhost",
5-
"hostRegex": "#^localhost$#si",
5+
"hostRegex": "#HOST_REGEX#",
66
"scheme": "http|https",
77
"method": "GET|HEAD",
8-
"class": "Symfony\\Component\\Routing\\Route",
8+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub",
99
"defaults": {
1010
"name": "Joseph"
1111
},

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
- Path: /hello/{name}
2-
- Path Regex: #^/hello(?:/(?P<name>[a-z]+))?$#s
2+
- Path Regex: #PATH_REGEX#
33
- Host: localhost
4-
- Host Regex: #^localhost$#si
4+
- Host Regex: #HOST_REGEX#
55
- Scheme: http|https
66
- Method: GET|HEAD
7-
- Class: Symfony\Component\Routing\Route
7+
- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub
88
- Defaults:
99
- `name`: Joseph
1010
- Requirements:
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
+--------------+---------------------------------------------------------+
2-
| Property | Value |
3-
+--------------+---------------------------------------------------------+
4-
| Route Name | |
5-
| Path | /hello/{name} |
6-
| Path Regex | #^/hello(?:/(?P<name>[a-z]+))?$#s |
7-
| Host | localhost |
8-
| Host Regex | #^localhost$#si |
9-
| Scheme | http|https |
10-
| Method | GET|HEAD |
11-
| Requirements | name: [a-z]+ |
12-
| Class | Symfony\Component\Routing\Route |
13-
| Defaults | name: Joseph |
14-
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15-
| | opt1: val1 |
16-
| | opt2: val2 |
17-
+--------------+---------------------------------------------------------+
1+
+--------------+-------------------------------------------------------------------+
2+
| Property | Value |
3+
+--------------+-------------------------------------------------------------------+
4+
| Route Name | |
5+
| Path | /hello/{name} |
6+
| Path Regex | #PATH_REGEX# |
7+
| Host | localhost |
8+
| Host Regex | #HOST_REGEX# |
9+
| Scheme | http|https |
10+
| Method | GET|HEAD |
11+
| Requirements | name: [a-z]+ |
12+
| Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub |
13+
| Defaults | name: Joseph |
14+
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15+
| | opt1: val1 |
16+
| | opt2: val2 |
17+
+--------------+-------------------------------------------------------------------+

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<route class="Symfony\Component\Routing\Route">
3-
<path regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">/hello/{name}</path>
4-
<host regex="#^localhost$#si">localhost</host>
2+
<route class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub">
3+
<path regex="#PATH_REGEX#">/hello/{name}</path>
4+
<host regex="#HOST_REGEX#">localhost</host>
55
<scheme>http</scheme>
66
<scheme>https</scheme>
77
<method>GET</method>

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"path": "\/name\/add",
3-
"pathRegex": "#^\/name\/add$#s",
3+
"pathRegex": "#PATH_REGEX#",
44
"host": "localhost",
5-
"hostRegex": "#^localhost$#si",
5+
"hostRegex": "#HOST_REGEX#",
66
"scheme": "http|https",
77
"method": "PUT|POST",
8-
"class": "Symfony\\Component\\Routing\\Route",
8+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub",
99
"defaults": [],
1010
"requirements": "NO CUSTOM",
1111
"options": {

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
- Path: /name/add
2-
- Path Regex: #^/name/add$#s
2+
- Path Regex: #PATH_REGEX#
33
- Host: localhost
4-
- Host Regex: #^localhost$#si
4+
- Host Regex: #HOST_REGEX#
55
- Scheme: http|https
66
- Method: PUT|POS F440 T
7-
- Class: Symfony\Component\Routing\Route
7+
- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub
88
- Defaults: NONE
99
- Requirements: NO CUSTOM
1010
- Options:
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
+--------------+---------------------------------------------------------+
2-
| Property | Value |
3-
+--------------+---------------------------------------------------------+
4-
| Route Name | |
5-
| Path | /name/add |
6-
| Path Regex | #^/name/add$#s |
7-
| Host | localhost |
8-
| Host Regex | #^localhost$#si |
9-
| Scheme | http|https |
10-
| Method | PUT|POST |
11-
| Requirements | NO CUSTOM |
12-
| Class | Symfony\Component\Routing\Route |
13-
| Defaults | NONE |
14-
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15-
| | opt1: val1 |
16-
| | opt2: val2 |
17-
+--------------+---------------------------------------------------------+
1+
+--------------+-------------------------------------------------------------------+
2+
| Property | Value |
3+
+--------------+-------------------------------------------------------------------+
4+
| Route Name | |
5+
| Path | /name/add |
6+
| Path Regex | #PATH_REGEX# |
7+
| Host | localhost |
8+
| Host Regex | #HOST_REGEX# |
9+
| Scheme | http|https |
10+
| Method | PUT|POST |
11+
| Requirements | NO CUSTOM |
12+
| Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub |
13+
| Defaults | NONE |
14+
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15+
| | opt1: val1 |
16+
| | opt2: val2 |
17+
+--------------+-------------------------------------------------------------------+

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<route class="Symfony\Component\Routing\Route">
3-
<path regex="#^/name/add$#s">/name/add</path>
4-
<host regex="#^localhost$#si">localhost</host>
2+
<route class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub">
3+
<path regex="#PATH_REGEX#">/name/add</path>
4+
<host regex="#HOST_REGEX#">localhost</host>
55
<scheme>http</scheme>
66
<scheme>https</scheme>
77
<method>PUT</method>

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"route_1": {
33
"path": "\/hello\/{name}",
4-
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s",
4+
"pathRegex": "#PATH_REGEX#",
55
"host": "localhost",
6-
"hostRegex": "#^localhost$#si",
6+
"hostRegex": "#HOST_REGEX#",
77
"scheme": "http|https",
88
"method": "GET|HEAD",
9-
"class": "Symfony\\Component\\Routing\\Route",
9+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub",
1010
"defaults": {
1111
"name": "Joseph"
1212
},
@@ -21,12 +21,12 @@
2121
},
2222
"route_2": {
2323
"path": "\/name\/add",
24-
"pathRegex": "#^\/name\/add$#s",
24+
"pathRegex": "#PATH_REGEX#",
2525
"host": "localhost",
26-
"hostRegex": "#^localhost$#si",
26+
"hostRegex": "#HOST_REGEX#",
2727
"scheme": "http|https",
2828
"method": "PUT|POST",
29-
"class": "Symfony\\Component\\Routing\\Route",
29+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub",
3030
"defaults": [],
3131
"requirements": "NO CUSTOM",
3232
"options": {

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ route_1
22
-------
33

44
- Path: /hello/{name}
5-
- Path Regex: #^/hello(?:/(?P<name>[a-z]+))?$#s
5+
- Path Regex: #PATH_REGEX#
66
- Host: localhost
7-
- Host Regex: #^localhost$#si
7+
- Host Regex: #HOST_REGEX#
88
- Scheme: http|https
99
- Method: GET|HEAD
10-
- Class: Symfony\Component\Routing\Route
10+
- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub
1111
- Defaults:
1212
- `name`: Joseph
1313
- Requirements:
@@ -22,12 +22,12 @@ route_2
2222
-------
2323

2424
- Path: /name/add
25-
- Path Regex: #^/name/add$#s
25+
- Path Regex: #PATH_REGEX#
2626
- Host: localhost
27-
- Host Regex: #^localhost$#si
27+
- Host Regex: #HOST_REGEX#
2828
- Scheme: http|https
2929
- Method: PUT|POST
30-
- Class: Symfony\Component\Routing\Route
30+
- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub
3131
- Defaults: NONE
3232
- Requirements: NO CUSTOM
3333
- Options:

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<routes>
3-
<route name="route_1" class="Symfony\Component\Routing\Route">
4-
<path regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">/hello/{name}</path>
5-
<host regex="#^localhost$#si">localhost</host>
3+
<route name="route_1" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub">
4+
<path regex="#PATH_REGEX#">/hello/{name}</path>
5+
<host regex="#HOST_REGEX#">localhost</host>
66
<scheme>http</scheme>
77
<scheme>https</scheme>
88
<method>GET</method>
@@ -19,9 +19,9 @@
1919
<option key="opt2">val2</option>
2020
</options>
2121
</route>
22-
<route name="route_2" class="Symfony\Component\Routing\Route">
23-
<path regex="#^/name/add$#s">/name/add</path>
24-
<host regex="#^localhost$#si">localhost</host>
22+
<route name="route_2" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub">
23+
<path regex="#PATH_REGEX#">/name/add</path>
24+
<host regex="#HOST_REGEX#">localhost</host>
2525
<scheme>http</scheme>
2626
<scheme>https</scheme>
2727
<method>PUT</method>

src/Symfony/Component/Routing/RouteCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private static function compilePattern(Route $route, $pattern, $isHost)
177177

178178
return array(
179179
'staticPrefix' => 'text' === $tokens[0][0] ? $tokens[0][1] : '',
180-
'regex' => self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s'.($isHost ? 'i' : ''),
180+
'regex' => self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'sD'.($isHost ? 'i' : ''),
181181
'tokens' => array_reverse($tokens),
182182
'variables' => $variables,
183183
);

0 commit comments

Comments
 (0)
0