Skip to content

Commit 245dd72

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Routing] Throw 405 instead of 404 when redirect is not possible [Process] fix test case Add security.tl.xlf to legacy directory [Security][Validator] Add translations for Tagalog fixed typo Typo fix in security component lithuanian translation. [Process] Check PHP_BINDIR before $PATH in PhpExecutableFinder
2 parents e490d66 + aa3a04a commit 245dd72

File tree

10 files changed

+522
-27
lines changed

10 files changed

+522
-27
lines changed

src/Symfony/Component/Process/PhpExecutableFinder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function find($includeArgs = true)
6262
}
6363
}
6464

65+
if (is_executable($php = PHP_BINDIR.('\\' === DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
66+
return $php;
67+
}
68+
6569
$dirs = array(PHP_BINDIR);
6670
if ('\\' === DIRECTORY_SEPARATOR) {
6771
$dirs[] = 'C:\xampp\php\\';

src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testFindWithSuffix()
114114
//TODO maybe php executable is custom or even Windows
115115
if ('\\' === DIRECTORY_SEPARATOR) {
116116
$this->assertTrue(is_executable($current));
117-
$this->assertTrue((bool) preg_match('/'.addslashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes');
117+
$this->assertRegExp('/\\\\php\.(exe|bat|cmd|com)$/i', $current, '::find() returns the executable PHP with suffixes');
118118
}
119119
}
120120
}

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

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren
217217
$methods[] = 'HEAD';
218218
}
219219

220-
$supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods));
220+
$supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('GET', $methods));
221221

222222
if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
223223
if ($supportsTrailingSlash && '/' === substr($m['url'], -1)) {
@@ -258,34 +258,13 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren
258258
EOF;
259259

260260
$gotoname = 'not_'.preg_replace('/[^A-Za-z0-9_]/', '', $name);
261-
if ($methods) {
262-
if (1 === count($methods)) {
263-
$code .= <<<EOF
264-
if (\$this->context->getMethod() != '$methods[0]') {
265-
\$allow[] = '$methods[0]';
266-
goto $gotoname;
267-
}
268-
269-
270-
EOF;
271-
} else {
272-
$methods = implode("', '", $methods);
273-
$code .= <<<EOF
274-
if (!in_array(\$this->context->getMethod(), array('$methods'))) {
275-
\$allow = array_merge(\$allow, array('$methods'));
276-
goto $gotoname;
277-
}
278-
279-
280-
EOF;
281-
}
282-
}
283261

284262
if ($hasTrailingSlash) {
285263
$code .= <<<EOF
286264
if ('/' === substr(\$pathinfo, -1)) {
287265
// no-op
288266
} elseif (!in_array(\$this->context->getMethod(), array('HEAD', 'GET'))) {
267+
\$allow[] = 'GET';
289268
goto $gotoname;
290269
} else {
291270
return \$this->redirect(\$rawPathinfo.'/', '$name');
@@ -303,13 +282,41 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren
303282
$code .= <<<EOF
304283
\$requiredSchemes = $schemes;
305284
if (!isset(\$requiredSchemes[\$this->context->getScheme()])) {
285+
if (!in_array(\$this->context->getMethod(), array('HEAD', 'GET'))) {
286+
\$allow[] = 'GET';
287+
goto $gotoname;
288+
}
289+
306290
return \$this->redirect(\$rawPathinfo, '$name', key(\$requiredSchemes));
307291
}
308292
309293
310294
EOF;
311295
}
312296

297+
if ($methods) {
298+
if (1 === count($methods)) {
299+
$code .= <<<EOF
300+
if (\$this->context->getMethod() != '$methods[0]') {
301+
\$allow[] = '$methods[0]';
302+
goto $gotoname;
303+
}
304+
305+
306+
EOF;
307+
} else {
308+
$methods = implode("', '", $methods);
309+
$code .= <<<EOF
310+
if (!in_array(\$this->context->getMethod(), array('$methods'))) {
311+
\$allow = array_merge(\$allow, array('$methods'));
312+
goto $gotoname;
313+
}
314+
315+
316+
EOF;
317+
}
318+
}
319+
313320
// optimize parameters array
314321
if ($matches || $hostMatches) {
315322
$vars = array();
@@ -333,7 +340,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren
333340
}
334341
$code .= " }\n";
335342

336-
if ($methods || $hasTrailingSlash) {
343+
if ($hasTrailingSlash || $schemes || $methods) {
337344
$code .= " $gotoname:\n";
338345
}
339346

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function match($rawPathinfo)
6969
if ('/' === substr($pathinfo, -1)) {
7070
// no-op
7171
} elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) {
72+
$allow[] = 'GET';
7273
goto not_baz3;
7374
} else {
7475
return $this->redirect($rawPathinfo.'/', 'baz3');
@@ -85,6 +86,7 @@ public function match($rawPathinfo)
8586
if ('/' === substr($pathinfo, -1)) {
8687
// no-op
8788
} elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) {
89+
$allow[] = 'GET';
8890
goto not_baz4;
8991
} else {
9092
return $this->redirect($rawPathinfo.'/', 'baz4');
@@ -183,6 +185,7 @@ public function match($rawPathinfo)
183185
if ('/' === substr($pathinfo, -1)) {
184186
// no-op
185187
} elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) {
188+
$allow[] = 'GET';
186189
goto not_hey;
187190
} else {
188191
return $this->redirect($rawPathinfo.'/', 'hey');
@@ -333,21 +336,33 @@ public function match($rawPathinfo)
333336
if ('/secure' === $pathinfo) {
334337
$requiredSchemes = array ( 'https' => 0,);
335338
if (!isset($requiredSchemes[$this->context->getScheme()])) {
339+
if (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) {
340+
$allow[] = 'GET';
341+
goto not_secure;
342+
}
343+
336344
return $this->redirect($rawPathinfo, 'secure', key($requiredSchemes));
337345
}
338346

339347
return array('_route' => 'secure');
340348
}
349+
not_secure:
341350

342351
// nonsecure
343352
if ('/nonsecure' === $pathinfo) {
344353
$requiredSchemes = array ( 'http' => 0,);
345354
if (!isset($requiredSchemes[$this->context->getScheme()])) {
355+
if (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) {
356+
$allow[] = 'GET';
357+
goto not_nonsecure;
358+
}
359+
346360
return $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes));
347361
}
348362

349363
return array('_route' => 'nonsecure');
350364
}
365+
not_nonsecure:
351366

352367
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
353368
}

src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919

2020
class DumpedRedirectableUrlMatcherTest extends RedirectableUrlMatcherTest
2121
{
22+
/**
23+
* @expectedException \Symfony\Component\Routing\Exception\MethodNotAllowedException
24+
*/
25+
public function testRedirectWhenNoSlashForNonSafeMethod()
26+
{
27+
parent::testRedirectWhenNoSlashForNonSafeMethod();
28+
}
29+
2230
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
2331
{
2432
static $i = 0;

src/Symfony/Component/Security/Core/Resources/translations/security.lt.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</trans-unit>
99
<trans-unit id="2">
1010
<source>Authentication credentials could not be found.</source>
11-
<target>Nepavyko rasti autentifikacijos duomneų.</target>
11+
<target>Nepavyko rasti autentifikacijos duomenų.</target>
1212
</trans-unit>
1313
<trans-unit id="3">
1414
<source>Authentication request could not be processed due to a system problem.</source>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0"?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="file.ext">
4+
<body>
5+
<trans-unit id="1">
6+
<source>An authentication exception occurred.</source>
7+
<target>Isang pambihirang pagpaptunay ang nangyari.</target>
8+
</trans-unit>
9+
<trans-unit id="2">
10+
<source>Authentication credentials could not be found.</source>
11+
<target>Hindi mahanap ang mga kinakailangan na dokumento para sa pagpapatunay.</target>
12+
</trans-unit>
13+
<trans-unit id="3">
14+
<source>Authentication request could not be processed due to a system problem.</source>
15+
<target>Hindi maproseso ang iyong hiling dahil may problema sa sistema.</target>
16+
</trans-unit>
17+
<trans-unit id="4">
18+
<source>Invalid credentials.</source>
19+
<target>Hindi balidong mga dokumento.</target>
20+
</trans-unit>
21+
<trans-unit id="5">
22+
<source>Cookie has already been used by someone else.</source>
23+
<target>Ang Cookie ay ginamit na ng ibang tao.</target>
24+
</trans-unit>
25+
<trans-unit id="6">
26+
<source>Not privileged to request the resource.</source>
27+
<target>Walang pribilehiyo upang humingi ng mga bagong mapagkukunan.</target>
28+
</trans-unit>
29+
<trans-unit id="7">
30+
<source>Invalid CSRF token.</source>
31+
<target>Hindi balidong mga token ng CSRF.</target>
32+
</trans-unit>
33+
<trans-unit id="8">
34+
<source>Digest nonce has expired.</source>
35+
<target>Na-expire na ang Digest nonce.</target>
36+
</trans-unit>
37+
<trans-unit id="9">
38+
<source>No authentication provider found to support the authentication token.</source>
39+
<target>Walang nakitang nagbibibagay ng suporta sa token ng pagpapatunay.</target>
40+
</trans-unit>
41+
<trans-unit id="10">
42+
<source>No session available, it either timed out or cookies are not enabled.</source>
43+
<target>Walang sesyon ng magagamit, ito ay nawalan ng oras o hindi pinagana.</target>
44+
</trans-unit>
45+
<trans-unit id="11">
46+
<source>No token could be found.</source>
47+
<target>Walang token na nahanap.</target>
48+
</trans-unit>
49+
<trans-unit id="12">
50+
<source>Username could not be found.</source>
51+
<target>Walang username na makita.</target>
52+
</trans-unit>
53+
<trans-unit id="13">
54+
<source>Account has expired.</source>
55+
<target>Ang akawnt ay nag-expire na.</target>
56+
</trans-unit>
57+
<trans-unit id="14">
58+
<source>Credentials have expired.</source>
59+
<target>.ng mga kinakailangang dokumento ay nag expire na.</target>
60+
</trans-unit>
61+
<trans-unit id="15">
62+
<source>Account is disabled.</source>
63+
<target>Ang akawnt ay hindi pinagana.</target>
64+
</trans-unit>
65+
<trans-unit id="16">
66+
<source>Account is locked.</source>
67+
<target>ng akawnt ay nakasara.</target>
68+
</trans-unit>
69+
</body>
70+
</file>
71+
</xliff>

src/Symfony/Component/Security/Resources/translations/security.lt.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</trans-unit>
99
<trans-unit id="2">
1010
<source>Authentication credentials could not be found.</source>
11-
<target>Nepavyko rasti autentifikacijos duomneų.</target>
11+
<target>Nepavyko rasti autentifikacijos duomenų.</target>
1212
</trans-unit>
1313
<trans-unit id="3">
1414
<source>Authentication request could not be processed due to a system problem.</source>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0"?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="file.ext">
4+
<body>
5+
<trans-unit id="1">
6+
<source>An authentication exception occurred.</source>
7+
<target>Isang pambihirang pagpaptunay ang nangyari.</target>
8+
</trans-unit>
9+
<trans-unit id="2">
10+
<source>Authentication credentials could not be found.</source>
11+
<target>Hindi mahanap ang mga kinakailangan na dokumento para sa pagpapatunay.</target>
12+
</trans-unit>
13+
<trans-unit id="3">
14+
<source>Authentication request could not be processed due to a system problem.</source>
15+
<target>Hindi maproseso ang iyong hiling dahil may problema sa sistema.</target>
16+
</trans-unit>
17+
<trans-unit id="4">
18+
<source>Invalid credentials.</source>
19+
<target>Hindi balidong mga dokumento.</target>
20+
</trans-unit>
21+
<trans-unit id="5">
22+
<source>Cookie has already been used by someone else.</source>
23+
<target>Ang Cookie ay ginamit na ng ibang tao.</target>
24+
</trans-unit>
25+
<trans-unit id="6">
26+
<source>Not privileged to request the resource.</source>
27+
<target>Walang pribilehiyo upang humingi ng mga bagong mapagkukunan.</target>
28+
</trans-unit>
29+
<trans-unit id="7">
30+
<source>Invalid CSRF token.</source>
31+
<target>Hindi balidong mga token ng CSRF.</target>
32+
</trans-unit>
33+
<trans-unit id="8">
34+
<source>Digest nonce has expired.</source>
35+
<target>Na-expire na ang Digest nonce.</target>
36+
</trans-unit>
37+
<trans-unit id="9">
38+
<source>No authentication provider found to support the authentication token.</source>
39+
<target>Walang nakitang nagbibibagay ng suporta sa token ng pagpapatunay.</target>
40+
</trans-unit>
41+
<trans-unit id="10">
42+
<source>No session available, it either timed out or cookies are not enabled.</source>
43+
<target>Walang sesyon ng magagamit, ito ay nawalan ng oras o hindi pinagana.</target>
44+
</trans-unit>
45+
<trans-unit id="11">
46+
<source>No token could be found.</source>
47+
<target>Walang token na nahanap.</target>
48+
</trans-unit>
49+
<trans-unit id="12">
50+
<source>Username could not be found.</source>
51+
<target>Walang username na makita.</target>
52+
</trans-unit>
53+
<trans-unit id="13">
54+
<source>Account has expired.</source>
55+
<target>Ang akawnt ay nag-expire na.</target>
56+
</trans-unit>
57+
<trans-unit id="14">
58+
<source>Credentials have expired.</source>
59+
<target>.ng mga kinakailangang dokumento ay nag expire na.</target>
60+
</trans-unit>
61+
<trans-unit id="15">
62+
<source>Account is disabled.</source>
63+
<target>Ang akawnt ay hindi pinagana.</target>
64+
</trans-unit>
65+
<trans-unit id="16">
66+
<source>Account is locked.</source>
67+
<target>ng akawnt ay nakasara.</target>
68+
</trans-unit>
69+
</body>
70+
</file>
71+
</xliff>

0 commit comments

Comments
 (0)