Skip to content

Commit 6ef6ebf

Browse files
Merge branch '3.4' into 4.0
* 3.4: Use the PCRE_DOLLAR_ENDONLY modifier in route regexes [Form] Make sure errors are a part of the label on bootstrap 4 - this is a requirement for WCAG2 [Config] Only using filemtime to check file freshness
2 parents 9b27de8 + 16369f2 commit 6ef6ebf

File tree

10 files changed

+117
-105
lines changed

10 files changed

+117
-105
lines changed

RouteCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private static function compilePattern(Route $route, $pattern, $isHost)
208208
for ($i = 0, $nbToken = count($tokens); $i < $nbToken; ++$i) {
209209
$regexp .= self::computeRegexp($tokens, $i, $firstOptional);
210210
}
211-
$regexp = self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s'.($isHost ? 'i' : '');
211+
$regexp = self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'sD'.($isHost ? 'i' : '');
212212

213213
// enable Utf8 matching if really required
214214
if ($needsUtf8) {

Tests/Fixtures/dumper/url_matcher1.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function match($rawPathinfo)
3030

3131
if (0 === strpos($pathinfo, '/foo')) {
3232
// foo
33-
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
33+
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#sD', $pathinfo, $matches)) {
3434
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
3535
}
3636

@@ -43,7 +43,7 @@ public function match($rawPathinfo)
4343

4444
elseif (0 === strpos($pathinfo, '/bar')) {
4545
// bar
46-
if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
46+
if (preg_match('#^/bar/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
4747
if ('GET' !== $canonicalMethod) {
4848
$allow[] = 'GET';
4949
goto not_bar;
@@ -54,7 +54,7 @@ public function match($rawPathinfo)
5454
not_bar:
5555

5656
// barhead
57-
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
57+
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
5858
if ('GET' !== $canonicalMethod) {
5959
$allow[] = 'GET';
6060
goto not_barhead;
@@ -86,12 +86,12 @@ public function match($rawPathinfo)
8686
}
8787

8888
// baz4
89-
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
89+
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
9090
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
9191
}
9292

9393
// baz5
94-
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
94+
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
9595
if ('POST' !== $canonicalMethod) {
9696
$allow[] = 'POST';
9797
goto not_baz5;
@@ -102,7 +102,7 @@ public function match($rawPathinfo)
102102
not_baz5:
103103

104104
// baz.baz6
105-
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
105+
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
106106
if ('PUT' !== $canonicalMethod) {
107107
$allow[] = 'PUT';
108108
goto not_bazbaz6;
@@ -115,7 +115,7 @@ public function match($rawPathinfo)
115115
}
116116

117117
// quoter
118-
if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
118+
if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
119119
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
120120
}
121121

@@ -127,30 +127,30 @@ public function match($rawPathinfo)
127127
if (0 === strpos($pathinfo, '/a')) {
128128
if (0 === strpos($pathinfo, '/a/b\'b')) {
129129
// foo1
130-
if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
130+
if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
131131
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ());
132132
}
133133

134134
// bar1
135-
if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
135+
if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
136136
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
137137
}
138138

139139
}
140140

141141
// overridden
142-
if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) {
142+
if (preg_match('#^/a/(?P<var>.*)$#sD', $pathinfo, $matches)) {
143143
return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ());
144144
}
145145

146146
if (0 === strpos($pathinfo, '/a/b\'b')) {
147147
// foo2
148-
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#s', $pathinfo, $matches)) {
148+
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#sD', $pathinfo, $matches)) {
149149
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
150150
}
151151

152152
// bar2
153-
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#s', $pathinfo, $matches)) {
153+
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
154154
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
155155
}
156156

@@ -160,7 +160,7 @@ public function match($rawPathinfo)
160160

161161
elseif (0 === strpos($pathinfo, '/multi')) {
162162
// helloWorld
163-
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) {
163+
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#sD', $pathinfo, $matches)) {
164164
return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',));
165165
}
166166

@@ -177,12 +177,12 @@ public function match($rawPathinfo)
177177
}
178178

179179
// foo3
180-
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
180+
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
181181
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ());
182182
}
183183

184184
// bar3
185-
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
185+
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
186186
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
187187
}
188188

@@ -193,15 +193,15 @@ public function match($rawPathinfo)
193193
}
194194

195195
// foo4
196-
if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
196+
if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
197197
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
198198
}
199199

200200
}
201201

202202
$host = $context->getHost();
203203

204-
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
204+
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
205205
// route1
206206
if ('/route1' === $pathinfo) {
207207
return array('_route' => 'route1');
@@ -214,23 +214,23 @@ public function match($rawPathinfo)
214214

215215
}
216216

217-
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
217+
if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
218218
// route3
219219
if ('/c2/route3' === $pathinfo) {
220220
return array('_route' => 'route3');
221221
}
222222

223223
}
224224

225-
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
225+
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
226226
// route4
227227
if ('/route4' === $pathinfo) {
228228
return array('_route' => 'route4');
229229
}
230230

231231
}
232232

233-
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
233+
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
234234
// route5
235235
if ('/route5' === $pathinfo) {
236236
return array('_route' => 'route5');
@@ -243,7 +243,7 @@ public function match($rawPathinfo)
243243
return array('_route' => 'route6');
244244
}
245245

246-
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
246+
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
247247
if (0 === strpos($pathinfo, '/route1')) {
248248
// route11
249249
if ('/route11' === $pathinfo) {
@@ -256,29 +256,29 @@ public function match($rawPathinfo)
256256
}
257257

258258
// route13
259-
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
259+
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
260260
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ());
261261
}
262262

263263
// route14
264-
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
264+
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
265265
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
266266
}
267267

268268
}
269269

270270
}
271271

272-
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
272+
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
273273
// route15
274-
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
274+
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
275275
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
276276
}
277277

278278
}
279279

280280
// route16
281-
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
281+
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
282282
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
283283
}
284284

@@ -294,12 +294,12 @@ public function match($rawPathinfo)
294294

295295
if (0 === strpos($pathinfo, '/a/b')) {
296296
// b
297-
if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
297+
if (preg_match('#^/a/b/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
298298
return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ());
299299
}
300300

301301
// c
302-
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
302+
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
303303
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
304304
}
305305

0 commit comments

Comments
 (0)