From 7a750d4508b6edbcf93f4149b79a96ef4a161485 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 4 Jun 2018 19:54:36 +0200 Subject: [PATCH] [Routing] Don't reorder past variable-length placeholders --- .../Matcher/Dumper/StaticPrefixCollection.php | 2 +- .../Tests/Fixtures/dumper/url_matcher12.php | 36 ++++++++----------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php index cd9e6b4c3e..030aeaed41 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php @@ -176,7 +176,7 @@ class StaticPrefixCollection break; } $subPattern = substr($prefix, $i, $j - $i); - if ($prefix !== $anotherPrefix && !preg_match('/^\(\[[^\]]++\]\+\+\)$/', $subPattern) && !preg_match('{(? '{^(?' - .'|/abc([^/]++)/(?' - .'|1(?' - .'|(*:27)' - .'|0(?' - .'|(*:38)' - .'|0(*:46)' - .')' - .')' - .'|2(?' - .'|(*:59)' - .'|0(?' - .'|(*:70)' - .'|0(*:78)' - .')' - .')' + .'|/abc(?' + .'|([^/]++)/1(*:24)' + .'|([^/]++)/2(*:41)' + .'|([^/]++)/10(*:59)' + .'|([^/]++)/20(*:77)' + .'|([^/]++)/100(*:96)' + .'|([^/]++)/200(*:115)' .')' .')$}sD', ); @@ -53,12 +45,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher switch ($m = (int) $matches['MARK']) { default: $routes = array( - 27 => array(array('_route' => 'r1'), array('foo'), null, null), - 38 => array(array('_route' => 'r10'), array('foo'), null, null), - 46 => array(array('_route' => 'r100'), array('foo'), null, null), - 59 => array(array('_route' => 'r2'), array('foo'), null, null), - 70 => array(array('_route' => 'r20'), array('foo'), null, null), - 78 => array(array('_route' => 'r200'), array('foo'), null, null), + 24 => array(array('_route' => 'r1'), array('foo'), null, null), + 41 => array(array('_route' => 'r2'), array('foo'), null, null), + 59 => array(array('_route' => 'r10'), array('foo'), null, null), + 77 => array(array('_route' => 'r20'), array('foo'), null, null), + 96 => array(array('_route' => 'r100'), array('foo'), null, null), + 115 => array(array('_route' => 'r200'), array('foo'), null, null), ); list($ret, $vars, $requiredMethods, $requiredSchemes) = $routes[$m]; @@ -84,7 +76,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher return $ret; } - if (78 === $m) { + if (115 === $m) { break; } $regex = substr_replace($regex, 'F', $m - $offset, 1 + strlen($m));