Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitc16efb4

Browse files
[Routing] fix matching host patterns, utf8 prefixes and non-capturing groups
1 parent8130f22 commitc16efb4

File tree

8 files changed

+131
-99
lines changed

8 files changed

+131
-99
lines changed

‎src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,10 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
376376
if ($hostRegex) {
377377
preg_match('#^.\^(.*)\$.[a-zA-Z]*$#',$hostRegex,$rx);
378378
$state->vars =array();
379-
$hostRegex ='(?i:'.preg_replace_callback('#\?P<([^>]++)>#',$state->getVars,$rx[1]).')';
379+
$hostRegex ='(?i:'.preg_replace_callback('#\?P<([^>]++)>#',$state->getVars,$rx[1]).')\.';
380380
$state->hostVars =$state->vars;
381381
}else {
382-
$hostRegex ='[^/]*+';
382+
$hostRegex ='(?:[^.]*+\.)++';
383383
$state->hostVars =array();
384384
}
385385
$state->mark +=strlen($rx = ($prev ?')' :'')."|{$hostRegex}(?");
@@ -427,7 +427,7 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
427427
EOF;
428428
}
429429

430-
$matchedPathinfo =$matchHost ?'$host.$pathinfo' :'$pathinfo';
430+
$matchedPathinfo =$matchHost ?'$host.\'.\'.$pathinfo' :'$pathinfo';
431431
unset($state->getVars);
432432

433433
return<<<EOF

‎src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ private function getCommonPrefix(string $prefix, string $anotherPrefix): array
187187
}
188188
}
189189
restore_error_handler();
190+
if ($i <$end &&0b10 === (\ord($prefix[$i]) >>6) &&preg_match('//u',$prefix.''.$anotherPrefix)) {
191+
do {
192+
--$i;
193+
}while (0b10 === (\ord($prefix[$i]) >>6));
194+
}
190195

191196
returnarray(substr($prefix,0,$i),substr($prefix,0,$staticLength ??$i));
192197
}

‎src/Symfony/Component/Routing/RouteCompiler.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ private static function transformCapturingGroupsToNonCapturings(string $regexp):
321321
continue;
322322
}
323323
$regexp =substr_replace($regexp,'?:',$i,0);
324-
$i +=2;
324+
++$i;
325325
}
326326

327327
return$regexp;

‎src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php‎

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -79,50 +79,50 @@ public function match($rawPathinfo)
7979
return$ret;
8080
}
8181

82-
$matchedPathinfo =$host.$pathinfo;
82+
$matchedPathinfo =$host.'.'.$pathinfo;
8383
$regexList =array(
8484
0 =>'{^(?'
85-
.'|[^/]*+(?'
86-
.'|/foo/(baz|symfony)(*:34)'
85+
.'|(?:[^.]*+\\.)++(?'
86+
.'|/foo/(baz|symfony)(*:42)'
8787
.'|/bar(?'
88-
.'|/([^/]++)(*:57)'
89-
.'|head/([^/]++)(*:77)'
88+
.'|/([^/]++)(*:65)'
89+
.'|head/([^/]++)(*:85)'
9090
.')'
9191
.'|/test/([^/]++)/(?'
92-
.'|(*:103)'
92+
.'|(*:111)'
9393
.')'
94-
.'|/([\']+)(*:119)'
94+
.'|/([\']+)(*:127)'
9595
.'|/a/(?'
9696
.'|b\'b/([^/]++)(?'
97-
.'|(*:148)'
9897
.'|(*:156)'
98+
.'|(*:164)'
9999
.')'
100-
.'|(.*)(*:169)'
100+
.'|(.*)(*:177)'
101101
.'|b\'b/([^/]++)(?'
102-
.'|(*:192)'
103102
.'|(*:200)'
103+
.'|(*:208)'
104104
.')'
105105
.')'
106-
.'|/multi/hello(?:/([^/]++))?(*:236)'
106+
.'|/multi/hello(?:/([^/]++))?(*:244)'
107107
.'|/([^/]++)/b/([^/]++)(?'
108-
.'|(*:267)'
109108
.'|(*:275)'
109+
.'|(*:283)'
110110
.')'
111-
.'|/aba/([^/]++)(*:297)'
112-
.')|(?i:([^\\.]++)\\.example\\.com)(?'
111+
.'|/aba/([^/]++)(*:305)'
112+
.')|(?i:([^\\.]++)\\.example\\.com)\\.(?'
113113
.'|/route1(?'
114-
.'|3/([^/]++)(*:357)'
115-
.'|4/([^/]++)(*:375)'
114+
.'|3/([^/]++)(*:367)'
115+
.'|4/([^/]++)(*:385)'
116116
.')'
117-
.')|(?i:c\\.example\\.com)(?'
118-
.'|/route15/([^/]++)(*:425)'
119-
.')|[^/]*+(?'
120-
.'|/route16/([^/]++)(*:460)'
117+
.')|(?i:c\\.example\\.com)\\.(?'
118+
.'|/route15/([^/]++)(*:437)'
119+
.')|(?:[^.]*+\\.)++(?'
120+
.'|/route16/([^/]++)(*:480)'
121121
.'|/a/(?'
122-
.'|a\\.\\.\\.(*:481)'
122+
.'|a\\.\\.\\.(*:501)'
123123
.'|b/(?'
124-
.'|([^/]++)(*:502)'
125-
.'|c/([^/]++)(*:520)'
124+
.'|([^/]++)(*:522)'
125+
.'|c/([^/]++)(*:540)'
126126
.')'
127127
.')'
128128
.')'
@@ -132,7 +132,7 @@ public function match($rawPathinfo)
132132
foreach ($regexListas$offset =>$regex) {
133133
while (preg_match($regex,$matchedPathinfo,$matches)) {
134134
switch ($m = (int)$matches['MARK']) {
135-
case103:
135+
case111:
136136
$matches =array('foo' =>$matches[1] ??null);
137137

138138
// baz4
@@ -159,7 +159,7 @@ public function match($rawPathinfo)
159159
not_bazbaz6:
160160

161161
break;
162-
case148:
162+
case156:
163163
$matches =array('foo' =>$matches[1] ??null);
164164

165165
// foo1
@@ -173,14 +173,14 @@ public function match($rawPathinfo)
173173
not_foo1:
174174

175175
break;
176-
case192:
176+
case200:
177177
$matches =array('foo1' =>$matches[1] ??null);
178178

179179
// foo2
180180
return$this->mergeDefaults(array('_route' =>'foo2') +$matches,array());
181181

182182
break;
183-
case267:
183+
case275:
184184
$matches =array('_locale' =>$matches[1] ??null,'foo' =>$matches[2] ??null);
185185

186186
// foo3
@@ -189,23 +189,23 @@ public function match($rawPathinfo)
189189
break;
190190
default:
191191
$routes =array(
192-
34 =>array(array('_route' =>'foo','def' =>'test'),array('bar'),null,null),
193-
57 =>array(array('_route' =>'bar'),array('foo'),array('GET' =>0,'HEAD' =>1),null),
194-
77 =>array(array('_route' =>'barhead'),array('foo'),array('GET' =>0),null),
195-
119 =>array(array('_route' =>'quoter'),array('quoter'),null,null),
196-
156 =>array(array('_route' =>'bar1'),array('bar'),null,null),
197-
169 =>array(array('_route' =>'overridden'),array('var'),null,null),
198-
200 =>array(array('_route' =>'bar2'),array('bar1'),null,null),
199-
236 =>array(array('_route' =>'helloWorld','who' =>'World!'),array('who'),null,null),
200-
275 =>array(array('_route' =>'bar3'),array('_locale','bar'),null,null),
201-
297 =>array(array('_route' =>'foo4'),array('foo'),null,null),
202-
357 =>array(array('_route' =>'route13'),array('var1','name'),null,null),
203-
375 =>array(array('_route' =>'route14','var1' =>'val'),array('var1','name'),null,null),
204-
425 =>array(array('_route' =>'route15'),array('name'),null,null),
205-
460 =>array(array('_route' =>'route16','var1' =>'val'),array('name'),null,null),
206-
481 =>array(array('_route' =>'a'),array(),null,null),
207-
502 =>array(array('_route' =>'b'),array('var'),null,null),
208-
520 =>array(array('_route' =>'c'),array('var'),null,null),
192+
42 =>array(array('_route' =>'foo','def' =>'test'),array('bar'),null,null),
193+
65 =>array(array('_route' =>'bar'),array('foo'),array('GET' =>0,'HEAD' =>1),null),
194+
85 =>array(array('_route' =>'barhead'),array('foo'),array('GET' =>0),null),
195+
127 =>array(array('_route' =>'quoter'),array('quoter'),null,null),
196+
164 =>array(array('_route' =>'bar1'),array('bar'),null,null),
197+
177 =>array(array('_route' =>'overridden'),array('var'),null,null),
198+
208 =>array(array('_route' =>'bar2'),array('bar1'),null,null),
199+
244 =>array(array('_route' =>'helloWorld','who' =>'World!'),array('who'),null,null),
200+
283 =>array(array('_route' =>'bar3'),array('_locale','bar'),null,null),
201+
305 =>array(array('_route' =>'foo4'),array('foo'),null,null),
202+
367 =>array(array('_route' =>'route13'),array('var1','name'),null,null),
203+
385 =>array(array('_route' =>'route14','var1' =>'val'),array('var1','name'),null,null),
204+
437 =>array(array('_route' =>'route15'),array('name'),null,null),
205+
480 =>array(array('_route' =>'route16','var1' =>'val'),array('name'),null,null),
206+
501 =>array(array('_route' =>'a'),array(),null,null),
207+
522 =>array(array('_route' =>'b'),array('var'),null,null),
208+
540 =>array(array('_route' =>'c'),array('var'),null,null),
209209
);
210210

211211
list($ret,$vars,$requiredMethods,$requiredSchemes) =$routes[$m];
@@ -231,7 +231,7 @@ public function match($rawPathinfo)
231231
return$ret;
232232
}
233233

234-
if (520 ===$m) {
234+
if (540 ===$m) {
235235
break;
236236
}
237237
$regex =substr_replace($regex,'F',$m -$offset,1 +strlen($m));

‎src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher13.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public function match($rawPathinfo)
2727
$canonicalMethod ='GET';
2828
}
2929

30-
$matchedPathinfo =$host.$pathinfo;
30+
$matchedPathinfo =$host.'.'.$pathinfo;
3131
$regexList =array(
3232
0 =>'{^(?'
33-
.'|(?i:([^\\.]++)\\.exampple\\.com)(?'
33+
.'|(?i:([^\\.]++)\\.exampple\\.com)\\.(?'
3434
.'|/abc([^/]++)(?'
35-
.'|(*:54)'
35+
.'|(*:56)'
3636
.')'
3737
.')'
3838
.')$}sD',
@@ -41,7 +41,7 @@ public function match($rawPathinfo)
4141
foreach ($regexListas$offset =>$regex) {
4242
while (preg_match($regex,$matchedPathinfo,$matches)) {
4343
switch ($m = (int)$matches['MARK']) {
44-
case54:
44+
case56:
4545
$matches =array('foo' =>$matches[1] ??null,'foo' =>$matches[2] ??null);
4646

4747
// r1
@@ -53,7 +53,7 @@ public function match($rawPathinfo)
5353
break;
5454
}
5555

56-
if (54 ===$m) {
56+
if (56 ===$m) {
5757
break;
5858
}
5959
$regex =substr_replace($regex,'F',$m -$offset,1 +strlen($m));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp