diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_horizontal_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_horizontal_layout.html.twig index e236d12cb7..e23e6f8a29 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_horizontal_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_horizontal_layout.html.twig @@ -28,7 +28,6 @@ col-sm-2 {{- form_label(form) -}}
{{- form_widget(form) -}} - {{- form_errors(form) -}}
{##} {%- endif -%} @@ -40,7 +39,6 @@ col-sm-2 {{- form_label(form) -}}
{{- form_widget(form) -}} - {{- form_errors(form) -}}
{##} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig index 15413f1c9a..12981e3462 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig @@ -39,7 +39,41 @@ {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} - {{- parent() -}} + + {%- if widget == 'single_text' -%} + {{- block('form_widget_simple') -}} + {%- else -%} + {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} +
+
+ + + + {%- if with_years %}{% endif -%} + {%- if with_months %}{% endif -%} + {%- if with_weeks %}{% endif -%} + {%- if with_days %}{% endif -%} + {%- if with_hours %}{% endif -%} + {%- if with_minutes %}{% endif -%} + {%- if with_seconds %}{% endif -%} + + + + + {%- if with_years %}{% endif -%} + {%- if with_months %}{% endif -%} + {%- if with_weeks %}{% endif -%} + {%- if with_days %}{% endif -%} + {%- if with_hours %}{% endif -%} + {%- if with_minutes %}{% endif -%} + {%- if with_seconds %}{% endif -%} + + +
{{ form_label(form.years) }}{{ form_label(form.months) }}{{ form_label(form.weeks) }}{{ form_label(form.days) }}{{ form_label(form.hours) }}{{ form_label(form.minutes) }}{{ form_label(form.seconds) }}
{{ form_widget(form.years) }}{{ form_widget(form.months) }}{{ form_widget(form.weeks) }}{{ form_widget(form.days) }}{{ form_widget(form.hours) }}{{ form_widget(form.minutes) }}{{ form_widget(form.seconds) }}
+
+ {%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%} +
+ {%- endif -%} {%- endblock dateinterval_widget %} {% block percent_widget -%} @@ -125,13 +159,28 @@ {# Labels #} {% block form_label -%} - {%- if compound is defined and compound -%} - {%- set element = 'legend' -%} - {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%} - {%- else -%} - {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} + {% if label is not same as(false) -%} + {%- if compound is defined and compound -%} + {%- set element = 'legend' -%} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%} + {%- else -%} + {%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} + {%- endif -%} + {% if required -%} + {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} + {%- endif -%} + {% if label is empty -%} + {%- if label_format is not empty -%} + {% set label = label_format|replace({ + '%name%': name, + '%id%': id, + }) %} + {%- else -%} + {% set label = name|humanize %} + {%- endif -%} + {%- endif -%} + <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %} {%- endif -%} - {{- parent() -}} {%- endblock form_label %} {% block checkbox_radio_label -%} @@ -169,7 +218,6 @@ <{{ element|default('div') }} class="form-group"> {{- form_label(form) -}} {{- form_widget(form) -}} - {{- form_errors(form) -}} {%- endblock form_row %} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php index 9eb2e874d6..ce5cc7880b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php @@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\CompiledRoute; use Symfony\Component\Routing\RouteCollection; class ObjectsProvider @@ -36,7 +37,7 @@ class ObjectsProvider public static function getRoutes() { return array( - 'route_1' => new Route( + 'route_1' => new RouteStub( '/hello/{name}', array('name' => 'Joseph'), array('name' => '[a-z]+'), @@ -45,7 +46,7 @@ class ObjectsProvider array('http', 'https'), array('get', 'head') ), - 'route_2' => new Route( + 'route_2' => new RouteStub( '/name/add', array(), array(), @@ -187,3 +188,11 @@ class ExtendedCallableClass extends CallableClass { } } + +class RouteStub extends Route +{ + public function compile() + { + return new CompiledRoute('', '#PATH_REGEX#', array(), array(), '#HOST_REGEX#'); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.json index beac79f1f8..1108109fb0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.json +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.json @@ -1,11 +1,11 @@ { "path": "\/hello\/{name}", - "pathRegex": "#^\/hello(?:\/(?P[a-z]+))?$#s", + "pathRegex": "#PATH_REGEX#", "host": "localhost", - "hostRegex": "#^localhost$#si", + "hostRegex": "#HOST_REGEX#", "scheme": "http|https", "method": "GET|HEAD", - "class": "Symfony\\Component\\Routing\\Route", + "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", "defaults": { "name": "Joseph" }, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md index 5bfba18b2c..c36d35c83e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md @@ -1,10 +1,10 @@ - Path: /hello/{name} -- Path Regex: #^/hello(?:/(?P[a-z]+))?$#s +- Path Regex: #PATH_REGEX# - Host: localhost -- Host Regex: #^localhost$#si +- Host Regex: #HOST_REGEX# - Scheme: http|https - Method: GET|HEAD -- Class: Symfony\Component\Routing\Route +- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub - Defaults: - `name`: Joseph - Requirements: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt index ed0bcca656..25074dfd18 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt @@ -1,17 +1,17 @@ -+--------------+---------------------------------------------------------+ -| Property | Value | -+--------------+---------------------------------------------------------+ -| Route Name | | -| Path | /hello/{name} | -| Path Regex | #^/hello(?:/(?P[a-z]+))?$#s | -| Host | localhost | -| Host Regex | #^localhost$#si | -| Scheme | http|https | -| Method | GET|HEAD | -| Requirements | name: [a-z]+ | -| Class | Symfony\Component\Routing\Route | -| Defaults | name: Joseph | -| Options | compiler_class: Symfony\Component\Routing\RouteCompiler | -| | opt1: val1 | -| | opt2: val2 | -+--------------+---------------------------------------------------------+ ++--------------+-------------------------------------------------------------------+ +| Property | Value | ++--------------+-------------------------------------------------------------------+ +| Route Name | | +| Path | /hello/{name} | +| Path Regex | #PATH_REGEX# | +| Host | localhost | +| Host Regex | #HOST_REGEX# | +| Scheme | http|https | +| Method | GET|HEAD | +| Requirements | name: [a-z]+ | +| Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub | +| Defaults | name: Joseph | +| Options | compiler_class: Symfony\Component\Routing\RouteCompiler | +| | opt1: val1 | +| | opt2: val2 | ++--------------+-------------------------------------------------------------------+ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.xml index b6040bdad1..9ff531c928 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.xml @@ -1,7 +1,7 @@ - - /hello/{name} - localhost + + /hello/{name} + localhost http https GET diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json index 58caf26d53..e190ef0cbf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json @@ -1,11 +1,11 @@ { "path": "\/name\/add", - "pathRegex": "#^\/name\/add$#s", + "pathRegex": "#PATH_REGEX#", "host": "localhost", - "hostRegex": "#^localhost$#si", + "hostRegex": "#HOST_REGEX#", "scheme": "http|https", "method": "PUT|POST", - "class": "Symfony\\Component\\Routing\\Route", + "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", "defaults": [], "requirements": "NO CUSTOM", "options": { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md index 0a3f84be17..1d776c5ffe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md @@ -1,10 +1,10 @@ - Path: /name/add -- Path Regex: #^/name/add$#s +- Path Regex: #PATH_REGEX# - Host: localhost -- Host Regex: #^localhost$#si +- Host Regex: #HOST_REGEX# - Scheme: http|https - Method: PUT|POST -- Class: Symfony\Component\Routing\Route +- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub - Defaults: NONE - Requirements: NO CUSTOM - Options: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt index 828f6316be..5593cc0d81 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt @@ -1,17 +1,17 @@ -+--------------+---------------------------------------------------------+ -| Property | Value | -+--------------+---------------------------------------------------------+ -| Route Name | | -| Path | /name/add | -| Path Regex | #^/name/add$#s | -| Host | localhost | -| Host Regex | #^localhost$#si | -| Scheme | http|https | -| Method | PUT|POST | -| Requirements | NO CUSTOM | -| Class | Symfony\Component\Routing\Route | -| Defaults | NONE | -| Options | compiler_class: Symfony\Component\Routing\RouteCompiler | -| | opt1: val1 | -| | opt2: val2 | -+--------------+---------------------------------------------------------+ ++--------------+-------------------------------------------------------------------+ +| Property | Value | ++--------------+-------------------------------------------------------------------+ +| Route Name | | +| Path | /name/add | +| Path Regex | #PATH_REGEX# | +| Host | localhost | +| Host Regex | #HOST_REGEX# | +| Scheme | http|https | +| Method | PUT|POST | +| Requirements | NO CUSTOM | +| Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub | +| Defaults | NONE | +| Options | compiler_class: Symfony\Component\Routing\RouteCompiler | +| | opt1: val1 | +| | opt2: val2 | ++--------------+-------------------------------------------------------------------+ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml index 0f94cf7c41..584ab1b12d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml @@ -1,7 +1,7 @@ - - /name/add - localhost + + /name/add + localhost http https PUT diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json index 350bffdb3a..bd60070ed5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json @@ -1,12 +1,12 @@ { "route_1": { "path": "\/hello\/{name}", - "pathRegex": "#^\/hello(?:\/(?P[a-z]+))?$#s", + "pathRegex": "#PATH_REGEX#", "host": "localhost", - "hostRegex": "#^localhost$#si", + "hostRegex": "#HOST_REGEX#", "scheme": "http|https", "method": "GET|HEAD", - "class": "Symfony\\Component\\Routing\\Route", + "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", "defaults": { "name": "Joseph" }, @@ -21,12 +21,12 @@ }, "route_2": { "path": "\/name\/add", - "pathRegex": "#^\/name\/add$#s", + "pathRegex": "#PATH_REGEX#", "host": "localhost", - "hostRegex": "#^localhost$#si", + "hostRegex": "#HOST_REGEX#", "scheme": "http|https", "method": "PUT|POST", - "class": "Symfony\\Component\\Routing\\Route", + "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", "defaults": [], "requirements": "NO CUSTOM", "options": { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md index 815f36e2cf..cbb70b4d31 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md @@ -2,12 +2,12 @@ route_1 ------- - Path: /hello/{name} -- Path Regex: #^/hello(?:/(?P[a-z]+))?$#s +- Path Regex: #PATH_REGEX# - Host: localhost -- Host Regex: #^localhost$#si +- Host Regex: #HOST_REGEX# - Scheme: http|https - Method: GET|HEAD -- Class: Symfony\Component\Routing\Route +- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub - Defaults: - `name`: Joseph - Requirements: @@ -22,12 +22,12 @@ route_2 ------- - Path: /name/add -- Path Regex: #^/name/add$#s +- Path Regex: #PATH_REGEX# - Host: localhost -- Host Regex: #^localhost$#si +- Host Regex: #HOST_REGEX# - Scheme: http|https - Method: PUT|POST -- Class: Symfony\Component\Routing\Route +- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub - Defaults: NONE - Requirements: NO CUSTOM - Options: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml index 6d17820c31..666a53730d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml @@ -1,8 +1,8 @@ - - /hello/{name} - localhost + + /hello/{name} + localhost http https GET @@ -19,9 +19,9 @@ - - /name/add - localhost + + /name/add + localhost http https PUT diff --git a/src/Symfony/Component/Config/Resource/FileResource.php b/src/Symfony/Component/Config/Resource/FileResource.php index 8fa97162d4..78d552a5ab 100644 --- a/src/Symfony/Component/Config/Resource/FileResource.php +++ b/src/Symfony/Component/Config/Resource/FileResource.php @@ -60,7 +60,7 @@ class FileResource implements SelfCheckingResourceInterface, \Serializable */ public function isFresh($timestamp) { - return file_exists($this->resource) && @filemtime($this->resource) <= $timestamp; + return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp; } public function serialize() diff --git a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php index c6cdaa206d..c5b7abf896 100644 --- a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php +++ b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php @@ -40,11 +40,11 @@ class ReflectionClassResource implements SelfCheckingResourceInterface, \Seriali } foreach ($this->files as $file => $v) { - if (!file_exists($file)) { + if (false === $filemtime = @filemtime($file)) { return false; } - if (@filemtime($file) > $timestamp) { + if ($filemtime > $timestamp) { return $this->hash === $this->computeHash(); } } diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php index 2833de7d91..23e6f141ca 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Tests; +use Symfony\Component\Form\FormError; + /** * Abstract class providing test cases for the Bootstrap 4 horizontal Twig form theme. * @@ -18,6 +20,30 @@ namespace Symfony\Component\Form\Tests; */ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4LayoutTest { + public function testRow() + { + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); + $form->addError(new FormError('[trans]Error![/trans]')); + $view = $form->createView(); + $html = $this->renderRow($view); + + $this->assertMatchesXpath($html, + '/div + [ + ./label[@for="name"] + [ + ./div[ + ./ul + [./li[.="[trans]Error![/trans]"]] + [count(./li)=1] + ] + ] + /following-sibling::div[./input[@id="name"]] + ] +' + ); + } + public function testLabelOnForm() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType'); diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php index 88ebd261b2..fdaa07e1c1 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php @@ -20,6 +20,30 @@ use Symfony\Component\Form\FormError; */ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest { + public function testRow() + { + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); + $form->addError(new FormError('[trans]Error![/trans]')); + $view = $form->createView(); + $html = $this->renderRow($view); + + $this->assertMatchesXpath($html, + '/div + [ + ./label[@for="name"] + [ + ./div[ + ./ul + [./li[.="[trans]Error![/trans]"]] + [count(./li)=1] + ] + ] + /following-sibling::input[@id="name"] + ] +' + ); + } + public function testLabelOnForm() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType'); diff --git a/src/Symfony/Component/Routing/RouteCompiler.php b/src/Symfony/Component/Routing/RouteCompiler.php index b89efafcf8..42ddde0077 100644 --- a/src/Symfony/Component/Routing/RouteCompiler.php +++ b/src/Symfony/Component/Routing/RouteCompiler.php @@ -208,7 +208,7 @@ class RouteCompiler implements RouteCompilerInterface for ($i = 0, $nbToken = count($tokens); $i < $nbToken; ++$i) { $regexp .= self::computeRegexp($tokens, $i, $firstOptional); } - $regexp = self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s'.($isHost ? 'i' : ''); + $regexp = self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'sD'.($isHost ? 'i' : ''); // enable Utf8 matching if really required if ($needsUtf8) { diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php index d1bb74ec1d..9506f0cbfc 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php @@ -30,7 +30,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (0 === strpos($pathinfo, '/foo')) { // foo - if (preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { + if (preg_match('#^/foo/(?Pbaz|symfony)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); } @@ -43,7 +43,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher elseif (0 === strpos($pathinfo, '/bar')) { // bar - if (preg_match('#^/bar/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/bar/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('GET' !== $canonicalMethod) { $allow[] = 'GET'; goto not_bar; @@ -54,7 +54,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher not_bar: // barhead - if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('GET' !== $canonicalMethod) { $allow[] = 'GET'; goto not_barhead; @@ -86,12 +86,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // baz4 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (preg_match('#^/test/(?P[^/]++)/$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); } // baz5 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (preg_match('#^/test/(?P[^/]++)/$#sD', $pathinfo, $matches)) { if ('POST' !== $canonicalMethod) { $allow[] = 'POST'; goto not_baz5; @@ -102,7 +102,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher not_baz5: // baz.baz6 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (preg_match('#^/test/(?P[^/]++)/$#sD', $pathinfo, $matches)) { if ('PUT' !== $canonicalMethod) { $allow[] = 'PUT'; goto not_bazbaz6; @@ -115,7 +115,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // quoter - if (preg_match('#^/(?P[\']+)$#s', $pathinfo, $matches)) { + if (preg_match('#^/(?P[\']+)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); } @@ -127,30 +127,30 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (0 === strpos($pathinfo, '/a')) { if (0 === strpos($pathinfo, '/a/b\'b')) { // foo1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b\'b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); } // bar1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b\'b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); } } // overridden - if (preg_match('#^/a/(?P.*)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/(?P.*)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ()); } if (0 === strpos($pathinfo, '/a/b\'b')) { // foo2 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b\'b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); } // bar2 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b\'b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); } @@ -160,7 +160,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher elseif (0 === strpos($pathinfo, '/multi')) { // helloWorld - if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); } @@ -177,12 +177,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // foo3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); } // bar3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ()); } @@ -193,7 +193,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // foo4 - if (preg_match('#^/aba/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/aba/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); } @@ -201,7 +201,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher $host = $context->getHost(); - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) { // route1 if ('/route1' === $pathinfo) { return array('_route' => 'route1'); @@ -214,7 +214,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } - if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) { // route3 if ('/c2/route3' === $pathinfo) { return array('_route' => 'route3'); @@ -222,7 +222,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) { // route4 if ('/route4' === $pathinfo) { return array('_route' => 'route4'); @@ -230,7 +230,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) { // route5 if ('/route5' === $pathinfo) { return array('_route' => 'route5'); @@ -243,7 +243,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher return array('_route' => 'route6'); } - if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) { if (0 === strpos($pathinfo, '/route1')) { // route11 if ('/route11' === $pathinfo) { @@ -256,12 +256,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // route13 - if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ()); } // route14 - if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); } @@ -269,16 +269,16 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) { // route15 - if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); } } // route16 - if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); } @@ -294,12 +294,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (0 === strpos($pathinfo, '/a/b')) { // b - if (preg_match('#^/a/b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ()); } // c - if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index 662c2cb9a7..69e8420e8d 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -30,7 +30,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (0 === strpos($pathinfo, '/foo')) { // foo - if (preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { + if (preg_match('#^/foo/(?Pbaz|symfony)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); } @@ -43,7 +43,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec elseif (0 === strpos($pathinfo, '/bar')) { // bar - if (preg_match('#^/bar/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/bar/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('GET' !== $canonicalMethod) { $allow[] = 'GET'; goto not_bar; @@ -54,7 +54,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec not_bar: // barhead - if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('GET' !== $canonicalMethod) { $allow[] = 'GET'; goto not_barhead; @@ -96,7 +96,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // baz4 - if (preg_match('#^/test/(?P[^/]++)/?$#s', $pathinfo, $matches)) { + if (preg_match('#^/test/(?P[^/]++)/?$#sD', $pathinfo, $matches)) { $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); if ('/' === substr($pathinfo, -1)) { // no-op @@ -111,7 +111,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec not_baz4: // baz5 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (preg_match('#^/test/(?P[^/]++)/$#sD', $pathinfo, $matches)) { if ('POST' !== $canonicalMethod) { $allow[] = 'POST'; goto not_baz5; @@ -122,7 +122,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec not_baz5: // baz.baz6 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (preg_match('#^/test/(?P[^/]++)/$#sD', $pathinfo, $matches)) { if ('PUT' !== $canonicalMethod) { $allow[] = 'PUT'; goto not_bazbaz6; @@ -135,7 +135,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // quoter - if (preg_match('#^/(?P[\']+)$#s', $pathinfo, $matches)) { + if (preg_match('#^/(?P[\']+)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); } @@ -147,30 +147,30 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (0 === strpos($pathinfo, '/a')) { if (0 === strpos($pathinfo, '/a/b\'b')) { // foo1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b\'b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); } // bar1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b\'b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); } } // overridden - if (preg_match('#^/a/(?P.*)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/(?P.*)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ()); } if (0 === strpos($pathinfo, '/a/b\'b')) { // foo2 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b\'b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); } // bar2 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b\'b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); } @@ -180,7 +180,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec elseif (0 === strpos($pathinfo, '/multi')) { // helloWorld - if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); } @@ -207,12 +207,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // foo3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); } // bar3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ()); } @@ -223,7 +223,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // foo4 - if (preg_match('#^/aba/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/aba/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); } @@ -231,7 +231,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $host = $context->getHost(); - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) { // route1 if ('/route1' === $pathinfo) { return array('_route' => 'route1'); @@ -244,7 +244,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } - if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) { // route3 if ('/c2/route3' === $pathinfo) { return array('_route' => 'route3'); @@ -252,7 +252,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) { // route4 if ('/route4' === $pathinfo) { return array('_route' => 'route4'); @@ -260,7 +260,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) { // route5 if ('/route5' === $pathinfo) { return array('_route' => 'route5'); @@ -273,7 +273,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec return array('_route' => 'route6'); } - if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) { if (0 === strpos($pathinfo, '/route1')) { // route11 if ('/route11' === $pathinfo) { @@ -286,12 +286,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // route13 - if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ()); } // route14 - if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); } @@ -299,16 +299,16 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { + if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) { // route15 - if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); } } // route16 - if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); } @@ -324,12 +324,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (0 === strpos($pathinfo, '/a/b')) { // b - if (preg_match('#^/a/b/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/a/b/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ()); } // c - if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php index 40edb4386f..cfa6d131a0 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php @@ -35,7 +35,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // dynamic - if (preg_match('#^/rootprefix/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/rootprefix/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ()); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php index f88ecaf15f..ab4d6da7bd 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php @@ -47,7 +47,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // a_wildcard - if (preg_match('#^/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (preg_match('#^/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'a_wildcard')), array ()); } @@ -100,7 +100,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // nested_wildcard - if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'nested_wildcard')), array ()); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php index 91079fcef7..90ea628a14 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php @@ -71,12 +71,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher elseif (0 === strpos($pathinfo, '/trailing/regex')) { // regex_trailing_slash_no_methods - if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P[^/]++)/$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ()); } // regex_trailing_slash_GET_method - if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P[^/]++)/$#sD', $pathinfo, $matches)) { if ('GET' !== $canonicalMethod) { $allow[] = 'GET'; goto not_regex_trailing_slash_GET_method; @@ -87,7 +87,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher not_regex_trailing_slash_GET_method: // regex_trailing_slash_HEAD_method - if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P[^/]++)/$#sD', $pathinfo, $matches)) { if ('HEAD' !== $requestMethod) { $allow[] = 'HEAD'; goto not_regex_trailing_slash_HEAD_method; @@ -98,7 +98,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher not_regex_trailing_slash_HEAD_method: // regex_trailing_slash_POST_method - if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P[^/]++)/$#sD', $pathinfo, $matches)) { if ('POST' !== $canonicalMethod) { $allow[] = 'POST'; goto not_regex_trailing_slash_POST_method; @@ -153,12 +153,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher elseif (0 === strpos($pathinfo, '/not-trailing/regex')) { // regex_not_trailing_slash_no_methods - if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ()); } // regex_not_trailing_slash_GET_method - if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('GET' !== $canonicalMethod) { $allow[] = 'GET'; goto not_regex_not_trailing_slash_GET_method; @@ -169,7 +169,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher not_regex_not_trailing_slash_GET_method: // regex_not_trailing_slash_HEAD_method - if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('HEAD' !== $requestMethod) { $allow[] = 'HEAD'; goto not_regex_not_trailing_slash_HEAD_method; @@ -180,7 +180,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher not_regex_not_trailing_slash_HEAD_method: // regex_not_trailing_slash_POST_method - if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('POST' !== $canonicalMethod) { $allow[] = 'POST'; goto not_regex_not_trailing_slash_POST_method; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php index a9c3fd2b5f..de486eea9b 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php @@ -99,7 +99,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec elseif (0 === strpos($pathinfo, '/trailing/regex')) { // regex_trailing_slash_no_methods - if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P[^/]++)/?$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P[^/]++)/?$#sD', $pathinfo, $matches)) { $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ()); if ('/' === substr($pathinfo, -1)) { // no-op @@ -114,7 +114,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec not_regex_trailing_slash_no_methods: // regex_trailing_slash_GET_method - if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P[^/]++)/?$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P[^/]++)/?$#sD', $pathinfo, $matches)) { if ('GET' !== $canonicalMethod) { $allow[] = 'GET'; goto not_regex_trailing_slash_GET_method; @@ -134,7 +134,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec not_regex_trailing_slash_GET_method: // regex_trailing_slash_HEAD_method - if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P[^/]++)/?$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P[^/]++)/?$#sD', $pathinfo, $matches)) { if ('HEAD' !== $requestMethod) { $allow[] = 'HEAD'; goto not_regex_trailing_slash_HEAD_method; @@ -154,7 +154,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec not_regex_trailing_slash_HEAD_method: // regex_trailing_slash_POST_method - if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P[^/]++)/$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P[^/]++)/$#sD', $pathinfo, $matches)) { if ('POST' !== $canonicalMethod) { $allow[] = 'POST'; goto not_regex_trailing_slash_POST_method; @@ -209,12 +209,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec elseif (0 === strpos($pathinfo, '/not-trailing/regex')) { // regex_not_trailing_slash_no_methods - if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P[^/]++)$#sD', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ()); } // regex_not_trailing_slash_GET_method - if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('GET' !== $canonicalMethod) { $allow[] = 'GET'; goto not_regex_not_trailing_slash_GET_method; @@ -225,7 +225,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec not_regex_not_trailing_slash_GET_method: // regex_not_trailing_slash_HEAD_method - if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('HEAD' !== $requestMethod) { $allow[] = 'HEAD'; goto not_regex_not_trailing_slash_HEAD_method; @@ -236,7 +236,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec not_regex_not_trailing_slash_HEAD_method: // regex_not_trailing_slash_POST_method - if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { + if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P[^/]++)$#sD', $pathinfo, $matches)) { if ('POST' !== $canonicalMethod) { $allow[] = 'POST'; goto not_regex_not_trailing_slash_POST_method; diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index 52e00f94e3..a4ed8b6b24 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -162,6 +162,18 @@ class UrlMatcherTest extends TestCase $this->assertEquals(array('_route' => '$péß^a|'), $matcher->match('/bar')); } + /** + * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException + */ + public function testTrailingEncodedNewlineIsNotOverlooked() + { + $collection = new RouteCollection(); + $collection->add('foo', new Route('/foo')); + + $matcher = $this->getUrlMatcher($collection); + $matcher->match('/foo%0a'); + } + public function testMatchNonAlpha() { $collection = new RouteCollection(); diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php index 0d114ec6a4..d9db127da9 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -38,7 +38,7 @@ class RouteCompilerTest extends TestCase array( 'Static route', array('/foo'), - '/foo', '#^/foo$#s', array(), array( + '/foo', '#^/foo$#sD', array(), array( array('text', '/foo'), ), ), @@ -46,7 +46,7 @@ class RouteCompilerTest extends TestCase array( 'Route with a variable', array('/foo/{bar}'), - '/foo', '#^/foo/(?P[^/]++)$#s', array('bar'), array( + '/foo', '#^/foo/(?P[^/]++)$#sD', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), ), @@ -55,7 +55,7 @@ class RouteCompilerTest extends TestCase array( 'Route with a variable that has a default value', array('/foo/{bar}', array('bar' => 'bar')), - '/foo', '#^/foo(?:/(?P[^/]++))?$#s', array('bar'), array( + '/foo', '#^/foo(?:/(?P[^/]++))?$#sD', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), ), @@ -64,7 +64,7 @@ class RouteCompilerTest extends TestCase array( 'Route with several variables', array('/foo/{bar}/{foobar}'), - '/foo', '#^/foo/(?P[^/]++)/(?P[^/]++)$#s', array('bar', 'foobar'), array( + '/foo', '#^/foo/(?P[^/]++)/(?P[^/]++)$#sD', array('bar', 'foobar'), array( array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), @@ -74,7 +74,7 @@ class RouteCompilerTest extends TestCase array( 'Route with several variables that have default values', array('/foo/{bar}/{foobar}', array('bar' => 'bar', 'foobar' => '')), - '/foo', '#^/foo(?:/(?P[^/]++)(?:/(?P[^/]++))?)?$#s', array('bar', 'foobar'), array( + '/foo', '#^/foo(?:/(?P[^/]++)(?:/(?P[^/]++))?)?$#sD', array('bar', 'foobar'), array( array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), @@ -84,7 +84,7 @@ class RouteCompilerTest extends TestCase array( 'Route with several variables but some of them have no default values', array('/foo/{bar}/{foobar}', array('bar' => 'bar')), - '/foo', '#^/foo/(?P[^/]++)/(?P[^/]++)$#s', array('bar', 'foobar'), array( + '/foo', '#^/foo/(?P[^/]++)/(?P[^/]++)$#sD', array('bar', 'foobar'), array( array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), @@ -94,7 +94,7 @@ class RouteCompilerTest extends TestCase array( 'Route with an optional variable as the first segment', array('/{bar}', array('bar' => 'bar')), - '', '#^/(?P[^/]++)?$#s', array('bar'), array( + '', '#^/(?P[^/]++)?$#sD', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), ), ), @@ -102,7 +102,7 @@ class RouteCompilerTest extends TestCase array( 'Route with a requirement of 0', array('/{bar}', array('bar' => null), array('bar' => '0')), - '', '#^/(?P0)?$#s', array('bar'), array( + '', '#^/(?P0)?$#sD', array('bar'), array( array('variable', '/', '0', 'bar'), ), ), @@ -110,7 +110,7 @@ class RouteCompilerTest extends TestCase array( 'Route with an optional variable as the first segment with requirements', array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')), - '', '#^/(?P(foo|bar))?$#s', array('bar'), array( + '', '#^/(?P(foo|bar))?$#sD', array('bar'), array( array('variable', '/', '(foo|bar)', 'bar'), ), ), @@ -118,7 +118,7 @@ class RouteCompilerTest extends TestCase array( 'Route with only optional variables', array('/{foo}/{bar}', array('foo' => 'foo', 'bar' => 'bar')), - '', '#^/(?P[^/]++)?(?:/(?P[^/]++))?$#s', array('foo', 'bar'), array( + '', '#^/(?P[^/]++)?(?:/(?P[^/]++))?$#sD', array('foo', 'bar'), array( array('variable', '/', '[^/]++', 'bar'), array('variable', '/', '[^/]++', 'foo'), ), @@ -127,7 +127,7 @@ class RouteCompilerTest extends TestCase array( 'Route with a variable in last position', array('/foo-{bar}'), - '/foo-', '#^/foo\-(?P[^/]++)$#s', array('bar'), array( + '/foo-', '#^/foo\-(?P[^/]++)$#sD', array('bar'), array( array('variable', '-', '[^/]++', 'bar'), array('text', '/foo'), ), @@ -136,7 +136,7 @@ class RouteCompilerTest extends TestCase array( 'Route with nested placeholders', array('/{static{var}static}'), - '/{static', '#^/\{static(?P[^/]+)static\}$#s', array('var'), array( + '/{static', '#^/\{static(?P[^/]+)static\}$#sD', array('var'), array( array('text', 'static}'), array('variable', '', '[^/]+', 'var'), array('text', '/{static'), @@ -146,7 +146,7 @@ class RouteCompilerTest extends TestCase array( 'Route without separator between variables', array('/{w}{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => '(y|Y)')), - '', '#^/(?P[^/\.]+)(?P[^/\.]+)(?P(y|Y))(?:(?P[^/\.]++)(?:\.(?P<_format>[^/]++))?)?$#s', array('w', 'x', 'y', 'z', '_format'), array( + '', '#^/(?P[^/\.]+)(?P[^/\.]+)(?P(y|Y))(?:(?P[^/\.]++)(?:\.(?P<_format>[^/]++))?)?$#sD', array('w', 'x', 'y', 'z', '_format'), array( array('variable', '.', '[^/]++', '_format'), array('variable', '', '[^/\.]++', 'z'), array('variable', '', '(y|Y)', 'y'), @@ -158,7 +158,7 @@ class RouteCompilerTest extends TestCase array( 'Route with a format', array('/foo/{bar}.{_format}'), - '/foo', '#^/foo/(?P[^/\.]++)\.(?P<_format>[^/]++)$#s', array('bar', '_format'), array( + '/foo', '#^/foo/(?P[^/\.]++)\.(?P<_format>[^/]++)$#sD', array('bar', '_format'), array( array('variable', '.', '[^/]++', '_format'), array('variable', '/', '[^/\.]++', 'bar'), array('text', '/foo'), @@ -168,7 +168,7 @@ class RouteCompilerTest extends TestCase array( 'Static non UTF-8 route', array("/fo\xE9"), - "/fo\xE9", "#^/fo\xE9$#s", array(), array( + "/fo\xE9", "#^/fo\xE9$#sD", array(), array( array('text', "/fo\xE9"), ), ), @@ -176,7 +176,7 @@ class RouteCompilerTest extends TestCase array( 'Route with an explicit UTF-8 requirement', array('/{bar}', array('bar' => null), array('bar' => '.'), array('utf8' => true)), - '', '#^/(?P.)?$#su', array('bar'), array( + '', '#^/(?P.)?$#sDu', array('bar'), array( array('variable', '/', '.', 'bar', true), ), ), @@ -205,7 +205,7 @@ class RouteCompilerTest extends TestCase array( 'Static UTF-8 route', array('/foé'), - '/foé', '#^/foé$#su', array(), array( + '/foé', '#^/foé$#sDu', array(), array( array('text', '/foé'), ), 'patterns', @@ -214,7 +214,7 @@ class RouteCompilerTest extends TestCase array( 'Route with an implicit UTF-8 requirement', array('/{bar}', array('bar' => null), array('bar' => 'é')), - '', '#^/(?Pé)?$#su', array('bar'), array( + '', '#^/(?Pé)?$#sDu', array('bar'), array( array('variable', '/', 'é', 'bar', true), ), 'requirements', @@ -223,7 +223,7 @@ class RouteCompilerTest extends TestCase array( 'Route with a UTF-8 class requirement', array('/{bar}', array('bar' => null), array('bar' => '\pM')), - '', '#^/(?P\pM)?$#su', array('bar'), array( + '', '#^/(?P\pM)?$#sDu', array('bar'), array( array('variable', '/', '\pM', 'bar', true), ), 'requirements', @@ -232,7 +232,7 @@ class RouteCompilerTest extends TestCase array( 'Route with a UTF-8 separator', array('/foo/{bar}§{_format}', array(), array(), array('compiler_class' => Utf8RouteCompiler::class)), - '/foo', '#^/foo/(?P[^/§]++)§(?P<_format>[^/]++)$#su', array('bar', '_format'), array( + '/foo', '#^/foo/(?P[^/§]++)§(?P<_format>[^/]++)$#sDu', array('bar', '_format'), array( array('variable', '§', '[^/]++', '_format', true), array('variable', '/', '[^/§]++', 'bar', true), array('text', '/foo'), @@ -326,21 +326,21 @@ class RouteCompilerTest extends TestCase array( 'Route with host pattern', array('/hello', array(), array(), array(), 'www.example.com'), - '/hello', '#^/hello$#s', array(), array(), array( + '/hello', '#^/hello$#sD', array(), array(), array( array('text', '/hello'), ), - '#^www\.example\.com$#si', array(), array( + '#^www\.example\.com$#sDi', array(), array( array('text', 'www.example.com'), ), ), array( 'Route with host pattern and some variables', array('/hello/{name}', array(), array(), array(), 'www.example.{tld}'), - '/hello', '#^/hello/(?P[^/]++)$#s', array('tld', 'name'), array('name'), array( + '/hello', '#^/hello/(?P[^/]++)$#sD', array('tld', 'name'), array('name'), array( array('variable', '/', '[^/]++', 'name'), array('text', '/hello'), ), - '#^www\.example\.(?P[^\.]++)$#si', array('tld'), array( + '#^www\.example\.(?P[^\.]++)$#sDi', array('tld'), array( array('variable', '.', '[^\.]++', 'tld'), array('text', 'www.example'), ), @@ -348,10 +348,10 @@ class RouteCompilerTest extends TestCase array( 'Route with variable at beginning of host', array('/hello', array(), array(), array(), '{locale}.example.{tld}'), - '/hello', '#^/hello$#s', array('locale', 'tld'), array(), array( + '/hello', '#^/hello$#sD', array('locale', 'tld'), array(), array( array('text', '/hello'), ), - '#^(?P[^\.]++)\.example\.(?P[^\.]++)$#si', array('locale', 'tld'), array( + '#^(?P[^\.]++)\.example\.(?P[^\.]++)$#sDi', array('locale', 'tld'), array( array('variable', '.', '[^\.]++', 'tld'), array('text', '.example'), array('variable', '', '[^\.]++', 'locale'), @@ -360,10 +360,10 @@ class RouteCompilerTest extends TestCase array( 'Route with host variables that has a default value', array('/hello', array('locale' => 'a', 'tld' => 'b'), array(), array(), '{locale}.example.{tld}'), - '/hello', '#^/hello$#s', array('locale', 'tld'), array(), array( + '/hello', '#^/hello$#sD', array('locale', 'tld'), array(), array( array('text', '/hello'), ), - '#^(?P[^\.]++)\.example\.(?P[^\.]++)$#si', array('locale', 'tld'), array( + '#^(?P[^\.]++)\.example\.(?P[^\.]++)$#sDi', array('locale', 'tld'), array( array('variable', '.', '[^\.]++', 'tld'), array('text', '.example'), array('variable', '', '[^\.]++', 'locale'), diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index ff7e320c5f..c7af058e3b 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -245,7 +245,7 @@ class RouteTest extends TestCase */ public function testSerializedRepresentationKeepsWorking() { - $serialized = 'C:31:"Symfony\Component\Routing\Route":934:{a:8:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:8:"compiled";C:39:"Symfony\Component\Routing\CompiledRoute":569:{a:8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:30:"#^/prefix(?:/(?P\d+))?$#s";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:39:"#^(?P[^\.]++)\.example\.net$#si";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}}}'; + $serialized = 'C:31:"Symfony\Component\Routing\Route":936:{a:8:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:8:"compiled";C:39:"Symfony\Component\Routing\CompiledRoute":571:{a:8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:31:"#^/prefix(?:/(?P\d+))?$#sD";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:40:"#^(?P[^\.]++)\.example\.net$#sDi";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}}}'; $unserialized = unserialize($serialized); $route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+'));