From 3a470c4ecf25f921a36a549bca3205bb5d1cba77 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 4 Feb 2018 17:22:42 +0100 Subject: [PATCH 1/8] [Process] Check PHP_BINDIR before $PATH in PhpExecutableFinder --- src/Symfony/Component/Process/PhpExecutableFinder.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index fb297825fe..25415eda79 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -62,6 +62,10 @@ class PhpExecutableFinder } } + if (is_executable($php = PHP_BINDIR.'/php'.('\\' === DIRECTORY_SEPARATOR ? '.exe' : ''))) { + return $php; + } + $dirs = array(PHP_BINDIR); if ('\\' === DIRECTORY_SEPARATOR) { $dirs[] = 'C:\xampp\php\\'; From da39e01eb9ce3bcc083006c1baf8eadc4cf146a7 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Fri, 9 Feb 2018 15:45:43 +0100 Subject: [PATCH 2/8] [TwigBundle][WebProfilerBundle] Fix JS collision --- .../Resources/views/base_js.html.twig | 22 +++++++++++-------- .../views/Profiler/base_js.html.twig | 22 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig index 0ac832ee06..1bc9ccf14c 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig @@ -37,7 +37,7 @@ addEventListener: addEventListener, createTabs: function() { - var tabGroups = document.querySelectorAll('.sf-tabs'); + var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])'); /* create the tab navigation for each group of tabs */ for (var i = 0; i < tabGroups.length; i++) { @@ -99,11 +99,13 @@ document.getElementById(activeTabId).className = 'block'; }); } + + tabGroups[i].setAttribute('data-processed', 'true'); } }, createToggles: function() { - var toggles = document.querySelectorAll('.sf-toggle'); + var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])'); for (var i = 0; i < toggles.length; i++) { var elementSelector = toggles[i].getAttribute('data-toggle-selector'); @@ -156,14 +158,16 @@ var altContent = toggle.getAttribute('data-toggle-alt-content'); toggle.innerHTML = currentContent !== altContent ? altContent : originalContent; }); - } - /* Prevents from disallowing clicks on links inside toggles */ - var toggleLinks = document.querySelectorAll('.sf-toggle a'); - for (var i = 0; i < toggleLinks.length; i++) { - addEventListener(toggleLinks[i], 'click', function(e) { - e.stopPropagation(); - }); + /* Prevents from disallowing clicks on links inside toggles */ + var toggleLinks = toggles[i].querySelectorAll('a'); + for (var j = 0; j < toggleLinks.length; j++) { + addEventListener(toggleLinks[j], 'click', function(e) { + e.stopPropagation(); + }); + } + + toggles[i].setAttribute('data-processed', 'true'); } } }; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig index 7b26275ca8..5c2be8c74c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig @@ -393,7 +393,7 @@ }, createTabs: function() { - var tabGroups = document.querySelectorAll('.sf-tabs'); + var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])'); /* create the tab navigation for each group of tabs */ for (var i = 0; i < tabGroups.length; i++) { @@ -455,11 +455,13 @@ document.getElementById(activeTabId).className = 'block'; }); } + + tabGroups[i].setAttribute('data-processed', 'true'); } }, createToggles: function() { - var toggles = document.querySelectorAll('.sf-toggle'); + var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])'); for (var i = 0; i < toggles.length; i++) { var elementSelector = toggles[i].getAttribute('data-toggle-selector'); @@ -512,14 +514,16 @@ var altContent = toggle.getAttribute('data-toggle-alt-content'); toggle.innerHTML = currentContent !== altContent ? altContent : originalContent; }); - } - /* Prevents from disallowing clicks on links inside toggles */ - var toggleLinks = document.querySelectorAll('.sf-toggle a'); - for (var i = 0; i < toggleLinks.length; i++) { - addEventListener(toggleLinks[i], 'click', function(e) { - e.stopPropagation(); - }); + /* Prevents from disallowing clicks on links inside toggles */ + var toggleLinks = toggles[i].querySelectorAll('a'); + for (var j = 0; j < toggleLinks.length; j++) { + addEventListener(toggleLinks[j], 'click', function(e) { + e.stopPropagation(); + }); + } + + toggles[i].setAttribute('data-processed', 'true'); } } }; From a0d8b04f7fe93de908869633ebaa5647d051384b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rokas=20Mikalk=C4=97nas?= Date: Mon, 12 Feb 2018 08:50:32 +0200 Subject: [PATCH 3/8] Typo fix in security component lithuanian translation. --- .../Security/Core/Resources/translations/security.lt.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.lt.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.lt.xlf index da6c332b43..63e1ed662e 100644 --- a/src/Symfony/Component/Security/Core/Resources/translations/security.lt.xlf +++ b/src/Symfony/Component/Security/Core/Resources/translations/security.lt.xlf @@ -8,7 +8,7 @@ Authentication credentials could not be found. - Nepavyko rasti autentifikacijos duomneų. + Nepavyko rasti autentifikacijos duomenų. Authentication request could not be processed due to a system problem. From 2f7f9efbc67c400141242c1a0e12b486ef161af1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 12 Feb 2018 08:05:20 +0100 Subject: [PATCH 4/8] fixed typo --- .../Component/Security/Resources/translations/security.lt.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Resources/translations/security.lt.xlf b/src/Symfony/Component/Security/Resources/translations/security.lt.xlf index da6c332b43..63e1ed662e 100644 --- a/src/Symfony/Component/Security/Resources/translations/security.lt.xlf +++ b/src/Symfony/Component/Security/Resources/translations/security.lt.xlf @@ -8,7 +8,7 @@ Authentication credentials could not be found. - Nepavyko rasti autentifikacijos duomneų. + Nepavyko rasti autentifikacijos duomenų. Authentication request could not be processed due to a system problem. From 60abecafb91dce9d4cccc7fb7abcff3ea3ccc762 Mon Sep 17 00:00:00 2001 From: ergiegonzaga <36328355+ergiegonzaga@users.noreply.github.com> Date: Sat, 10 Feb 2018 18:44:21 +0800 Subject: [PATCH 5/8] [Security][Validator] Add translations for Tagalog --- .../Resources/translations/security.tl.xlf | 71 ++++ .../Resources/translations/validators.tl.xlf | 319 ++++++++++++++++++ 2 files changed, 390 insertions(+) create mode 100644 src/Symfony/Component/Security/Core/Resources/translations/security.tl.xlf create mode 100644 src/Symfony/Component/Validator/Resources/translations/validators.tl.xlf diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.tl.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.tl.xlf new file mode 100644 index 0000000000..c74b10aea8 --- /dev/null +++ b/src/Symfony/Component/Security/Core/Resources/translations/security.tl.xlf @@ -0,0 +1,71 @@ + + + + + + An authentication exception occurred. + Isang pambihirang pagpaptunay ang nangyari. + + + Authentication credentials could not be found. + Hindi mahanap ang mga kinakailangan na dokumento para sa pagpapatunay. + + + Authentication request could not be processed due to a system problem. + Hindi maproseso ang iyong hiling dahil may problema sa sistema. + + + Invalid credentials. + Hindi balidong mga dokumento. + + + Cookie has already been used by someone else. + Ang Cookie ay ginamit na ng ibang tao. + + + Not privileged to request the resource. + Walang pribilehiyo upang humingi ng mga bagong mapagkukunan. + + + Invalid CSRF token. + Hindi balidong mga token ng CSRF. + + + Digest nonce has expired. + Na-expire na ang Digest nonce. + + + No authentication provider found to support the authentication token. + Walang nakitang nagbibibagay ng suporta sa token ng pagpapatunay. + + + No session available, it either timed out or cookies are not enabled. + Walang sesyon ng magagamit, ito ay nawalan ng oras o hindi pinagana. + + + No token could be found. + Walang token na nahanap. + + + Username could not be found. + Walang username na makita. + + + Account has expired. + Ang akawnt ay nag-expire na. + + + Credentials have expired. + .ng mga kinakailangang dokumento ay nag expire na. + + + Account is disabled. + Ang akawnt ay hindi pinagana. + + + Account is locked. + ng akawnt ay nakasara. + + + + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.tl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.tl.xlf new file mode 100644 index 0000000000..75dc329589 --- /dev/null +++ b/src/Symfony/Component/Validator/Resources/translations/validators.tl.xlf @@ -0,0 +1,319 @@ + + + + + + This value should be false. + Ang halaga nito ay dapat na huwad. + + + This value should be true. + Ang halaga nito ay dapat totoo. + + + This value should be of type {{ type }}. + Ang halaga nito ay dapat sa uri {{ type }}. + + + This value should be blank. + Ang halaga nito ay dapat walang laman. + + + The value you selected is not a valid choice. + Ang halaga ng iyong pinili ay hindi balidong pagpili. + + + You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. + Kailangan mong pumili ng pinakamababang {{ limit }} ng pagpilian.|Kailangan mong pumili ng pinakamababang {{ limit }} ng mga pagpipilian. + + + You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. + Kailangan mong pumili ng pinakamataas {{ limit }} ng pagpipilian.|Kailangan mong pumili ng pinakamataas {{ limit }} ng mga pagpipilian. + + + One or more of the given values is invalid. + Isa o higit pang mga halaga na binigay ay hindi balido. + + + This field was not expected. + Ang larangang ito ay hindi inaasahan. + + + This field is missing. + Ang patlang na ito ay nawawala. + + + This value is not a valid date. + Ang halagang ito ay hindi balidong petsa. + + + This value is not a valid datetime. + Ang halagang ito ay hindi wastong petsa/oras. + + + This value is not a valid email address. + Ang halagang ito ay hindi balidong address ng email. + + + The file could not be found. + Ang file na ito ay hindi makita. + + + The file is not readable. + Ang file na ito ay hindi mabasa. + + + The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. + Ang file na ito ay masyadong malaki ({{ size }} {{ suffix }}). Ang pinakamalaking sukat {{ limit }} {{ suffix }}. + + + The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. + Ang uri ng file ng mime ay hindi balido ({{ type }}).Ang mga pinapayagang uri ng mime ay ang {{ types }}. + + + This value should be {{ limit }} or less. + Ang halaga nito ay dapat na {{ limit }} or maliit pa. + + + This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. + Ang halaga nito ay masyadong mahaba.Ito ay dapat na {{ limit }} karakter o maliit pa.|Ang halaga nito ay masyadong mahaba. Ito ay dapat na {{ limit }} mga karakter o maliit pa. + + + This value should be {{ limit }} or more. + Ang halaga nito ay dapat na {{ limit }} o mas marami pa. + + + This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. + Ang halaga nito ay masyadong maliit. Ito ay dapat na {{ limit }} karakter o marami pa.|Ang halaga nito ay masyadong maliit. Ito ay dapat na {{ limit }} mga karakter o marami pa. + + + This value should not be blank. + Ang halaga na ito ay dapat na may laman. + + + This value should not be null. + Meron dapt itong halaga. + + + This value should be null. + Wala dapat itong halaga. + + + This value is not valid. + Hindi balido ang halagang ito. + + + This value is not a valid time. + Ang halagang ito ay hindi wastong oras. + + + This value is not a valid URL. + Hindi ito isang balidong URL. + + + The two values should be equal. + Ang dalwang halaga ay dapat magkapareha. + + + The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. + Ang file ay masyadong malaki. Ang pinapayagan halaga lamang ay {{ limit}} {{ suffix }}. + + + The file is too large. + Ang file na ito ay masyadong malaki. + + + The file could not be uploaded. + Ang file na ito ay hindi ma-upload. + + + This value should be a valid number. + Ang halaga nito ay dapat na wastong numero. + + + This file is not a valid image. + Ang file na ito ay hindi wastong imahe. + + + This is not a valid IP address. + Ito ay hindi wastong IP address. + + + This value is not a valid language. + Ang halaga na ito ay hindi balidong wika. + + + This value is not a valid locale. + Ito ay isang hindi wastong locale na halaga. + + + This value is not a valid country. + ng halaga na ito ay hindi wastong bansa. + + + This value is already used. + Ang halaga na ito ay ginamit na. + + + The size of the image could not be detected. + Ang sukat ng imahe ay hindi madetect. + + + The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. + Ang lapad ng imahe ay masyadong malaki ({{ width }}px). Ang pinapayagang lapay ay {{ max_width }}px. + + + The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. + Ang lapad ng imahe ay masyadong maliit ({{ width }}px). Ang pinakamaliit na pinapayagang lapad ay {{ min_width }}px. + + + The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. + Ang haba ng imahe ay masyadong mataas ({{ height }}px). Ang pinakmataas na haba ay {{ max_height }}px. + + + The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. + Ang haba ng imahe ay masyadong maliit ({{ height }}px). Ang inaasahang haba ay {{ min_height }}px. + + + This value should be the user's current password. + Ang halagang ito ay dapat na password ng kasalukuyang gumagamit. + + + This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. + Ang halagang ito ay dapat na eksakto sa {{ limit}} karakter.|Ang halagang ito ay dapat na eksakto sa {{ limit }} mga karakter. + + + The file was only partially uploaded. + Ang file na ito ay kahalating na upload lamang. + + + No file was uploaded. + Walang na upload na file. + + + No temporary folder was configured in php.ini. + Walang temporaryong folder ang naayos sa php.ini. + + + Cannot write temporary file to disk. + Temporaryong hindi makasulat ng file sa disk. + + + A PHP extension caused the upload to fail. + Ang dahilan ng pagkabigo ng pagupload ng files ay isang extension ng PHP. + + + This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. + Ang koleksyon na ito ay dapat magkaroon ng {{ limit }} elemento o marami pa.|Ang koleksyon na ito ay dapat magkaroon ng {{ limit }} mga elemento o marami pa. + + + This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. + Ang koleksyon na ito ay dapat magkaroon ng {{ limit }} elemento o maliit pa.|Ang koleksyon na ito ay dapat magkaroon ng {{ limit }} mga elemento o maliit pa. + + + This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. + Ang koleksyong ito ay magkaroon ng eksaktong {{ limit }} elemento.|Ang koleksyong ito ay magkaroon ng eksaktong {{ limit }} mga elemento. + + + Invalid card number. + Hindi wastong numero ng kard. + + + Unsupported card type or invalid card number. + Hindi supportadong uri ng kard o hindi wastong numero ng kard. + + + This is not a valid International Bank Account Number (IBAN). + Ito ay hindi isang balidong International Bank Account Number (IBAN). + + + This value is not a valid ISBN-10. + Ang halagang ito ay hindi balidong SBN-10. + + + This value is not a valid ISBN-13. + Ang halagang ito ay hindi balidong ISBN-13. + + + This value is neither a valid ISBN-10 nor a valid ISBN-13. + Ang halagang ito ay pwdeng isang balidong ISBN-10 o isang balidong ISBN-13. + + + This value is not a valid ISSN. + Ang halangang ito ay hindi isang balidong ISSN. + + + This value is not a valid currency. + Ang halagang ito ay hindi balidong pera. + + + This value should be equal to {{ compared_value }}. + Ito ay hindi dapat magkapareho sa {{ compared_value }}. + + + This value should be greater than {{ compared_value }}. + Ang halagang ito ay dapat tataas sa {{ compared_value }}. + + + This value should be greater than or equal to {{ compared_value }}. + Ang halagang ito ay dapat mas mataas o magkapareha sa {{ compared_value }}. + + + This value should be identical to {{ compared_value_type }} {{ compared_value }}. + Ang halagang ito ay dapat kapareha ng {{ compared_value_type }} {{ compared_value }}. + + + This value should be less than {{ compared_value }}. + Ang halagang ito ay dapat mas maliit sa {{ compared_value }}. + + + This value should be less than or equal to {{ compared_value }}. + Ang halagang ito ay dapat mas mmaliit o magkapareha sa {{ compared_value }}. + + + This value should not be equal to {{ compared_value }}. + Ang halagang ito ay hindi dapat magkapareha sa {{ compared_value }}. + + + This value should not be identical to {{ compared_value_type }} {{ compared_value }}. + Ang halagang ito ay hindi dapat magkapareha sa {{ compared_value_type }} {{ compared_value }}. + + + The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}. + Ang ratio ng imahe ay masyadong malaki ({{ ratio }}). Ang pinakamalaking ratio ay {{ max_ratio }}. + + + The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}. + ng ratio ng imahe ay masyadong maliit ({{ ratio }}). Ang pinamaliit na ratio ay {{ min_ratio }}. + + + The image is square ({{ width }}x{{ height }}px). Square images are not allowed. + Ang imahe ay kwadrado ({{ width }}x{{ height }}px). Ang mga kwadradong imahe ay hindi pwede. + + + The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed. + Ang orientasyon ng imahe ay nakalandscape ({{ width }}x{{ height }}px). Ang mga imaheng nakalandscape ang orientasyon ay hindi pwede. + + + The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed. + Ang orientasyon ng imahe ay nakaportrait ({{ width }}x{{ height }}px). PAng mga imaheng nakaportrait ang orientasyon ay hindi pwede. + + + An empty file is not allowed. + Ang file na walang laman ay hindi pwede. + + + The host could not be resolved. + Hindi maresolba ang host. + + + This value does not match the expected {{ charset }} charset. + Ang halaga ay hindi kapareha sa inaasahang {{ charset }} set ng karater. + + + This is not a valid Business Identifier Code (BIC). + Ito ay hindi isang balidong Business Identifier Code (BIC). + + + + From 45d288a4ae365c10035775cacee7262df1b92c7f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 12 Feb 2018 15:12:46 +0100 Subject: [PATCH 6/8] Add security.tl.xlf to legacy directory --- .../Resources/translations/security.tl.xlf | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/Symfony/Component/Security/Resources/translations/security.tl.xlf diff --git a/src/Symfony/Component/Security/Resources/translations/security.tl.xlf b/src/Symfony/Component/Security/Resources/translations/security.tl.xlf new file mode 100644 index 0000000000..c74b10aea8 --- /dev/null +++ b/src/Symfony/Component/Security/Resources/translations/security.tl.xlf @@ -0,0 +1,71 @@ + + + + + + An authentication exception occurred. + Isang pambihirang pagpaptunay ang nangyari. + + + Authentication credentials could not be found. + Hindi mahanap ang mga kinakailangan na dokumento para sa pagpapatunay. + + + Authentication request could not be processed due to a system problem. + Hindi maproseso ang iyong hiling dahil may problema sa sistema. + + + Invalid credentials. + Hindi balidong mga dokumento. + + + Cookie has already been used by someone else. + Ang Cookie ay ginamit na ng ibang tao. + + + Not privileged to request the resource. + Walang pribilehiyo upang humingi ng mga bagong mapagkukunan. + + + Invalid CSRF token. + Hindi balidong mga token ng CSRF. + + + Digest nonce has expired. + Na-expire na ang Digest nonce. + + + No authentication provider found to support the authentication token. + Walang nakitang nagbibibagay ng suporta sa token ng pagpapatunay. + + + No session available, it either timed out or cookies are not enabled. + Walang sesyon ng magagamit, ito ay nawalan ng oras o hindi pinagana. + + + No token could be found. + Walang token na nahanap. + + + Username could not be found. + Walang username na makita. + + + Account has expired. + Ang akawnt ay nag-expire na. + + + Credentials have expired. + .ng mga kinakailangang dokumento ay nag expire na. + + + Account is disabled. + Ang akawnt ay hindi pinagana. + + + Account is locked. + ng akawnt ay nakasara. + + + + From d317496b6b7f783c4a76871c169eb05cda3c714c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 12 Feb 2018 15:17:16 +0100 Subject: [PATCH 7/8] [Process] fix test case --- src/Symfony/Component/Process/PhpExecutableFinder.php | 2 +- src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index 25415eda79..4bc27fe4d4 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -62,7 +62,7 @@ class PhpExecutableFinder } } - if (is_executable($php = PHP_BINDIR.'/php'.('\\' === DIRECTORY_SEPARATOR ? '.exe' : ''))) { + if (is_executable($php = PHP_BINDIR.('\\' === DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) { return $php; } diff --git a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php index 23465e9e80..250534d675 100644 --- a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php @@ -94,7 +94,7 @@ class PhpExecutableFinderTest extends TestCase //TODO maybe php executable is custom or even Windows if ('\\' === DIRECTORY_SEPARATOR) { $this->assertTrue(is_executable($current)); - $this->assertTrue((bool) preg_match('/'.addslashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes'); + $this->assertRegExp('/\\\\php\.(exe|bat|cmd|com)$/i', $current, '::find() returns the executable PHP with suffixes'); } } } From 92842814f6693ee3c4e24cca5d061eb4de50eb5d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 8 Feb 2018 21:27:30 +0100 Subject: [PATCH 8/8] [Routing] Throw 405 instead of 404 when redirect is not possible --- .../Matcher/Dumper/PhpMatcherDumper.php | 69 ++++++++++--------- .../Tests/Fixtures/dumper/url_matcher2.php | 15 ++++ .../DumpedRedirectableUrlMatcherTest.php | 8 +++ 3 files changed, 61 insertions(+), 31 deletions(-) diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index 28ab3679f9..ac48ca978f 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -217,7 +217,7 @@ EOF; $methods[] = 'HEAD'; } - $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods)); + $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('GET', $methods)); if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P.*?)\$\1#', $compiledRoute->getRegex(), $m)) { if ($supportsTrailingSlash && '/' === substr($m['url'], -1)) { @@ -258,6 +258,42 @@ EOF; EOF; $gotoname = 'not_'.preg_replace('/[^A-Za-z0-9_]/', '', $name); + + if ($hasTrailingSlash) { + $code .= <<context->getMethod(), array('HEAD', 'GET'))) { + \$allow[] = 'GET'; + goto $gotoname; + } else { + return \$this->redirect(\$rawPathinfo.'/', '$name'); + } + + +EOF; + } + + if ($schemes = $route->getSchemes()) { + if (!$supportsRedirections) { + throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); + } + $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); + $code .= <<context->getScheme()])) { + if (!in_array(\$this->context->getMethod(), array('HEAD', 'GET'))) { + \$allow[] = 'GET'; + goto $gotoname; + } + + return \$this->redirect(\$rawPathinfo, '$name', key(\$requiredSchemes)); + } + + +EOF; + } + if ($methods) { if (1 === count($methods)) { $code .= <<context->getMethod(), array('HEAD', 'GET'))) { - goto $gotoname; - } else { - return \$this->redirect(\$rawPathinfo.'/', '$name'); - } - - -EOF; - } - - if ($schemes = $route->getSchemes()) { - if (!$supportsRedirections) { - throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); - } - $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); - $code .= <<context->getScheme()])) { - return \$this->redirect(\$rawPathinfo, '$name', key(\$requiredSchemes)); - } - - -EOF; - } - // optimize parameters array if ($matches || $hostMatches) { $vars = array(); @@ -333,7 +340,7 @@ EOF; } $code .= " }\n"; - if ($methods || $hasTrailingSlash) { + if ($hasTrailingSlash || $schemes || $methods) { $code .= " $gotoname:\n"; } 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 a7e7ce75be..467d53b3ed 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -69,6 +69,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if ('/' === substr($pathinfo, -1)) { // no-op } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + $allow[] = 'GET'; goto not_baz3; } else { return $this->redirect($rawPathinfo.'/', 'baz3'); @@ -85,6 +86,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if ('/' === substr($pathinfo, -1)) { // no-op } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + $allow[] = 'GET'; goto not_baz4; } else { return $this->redirect($rawPathinfo.'/', 'baz4'); @@ -183,6 +185,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if ('/' === substr($pathinfo, -1)) { // no-op } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + $allow[] = 'GET'; goto not_hey; } else { return $this->redirect($rawPathinfo.'/', 'hey'); @@ -333,21 +336,33 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if ('/secure' === $pathinfo) { $requiredSchemes = array ( 'https' => 0,); if (!isset($requiredSchemes[$this->context->getScheme()])) { + if (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + $allow[] = 'GET'; + goto not_secure; + } + return $this->redirect($rawPathinfo, 'secure', key($requiredSchemes)); } return array('_route' => 'secure'); } + not_secure: // nonsecure if ('/nonsecure' === $pathinfo) { $requiredSchemes = array ( 'http' => 0,); if (!isset($requiredSchemes[$this->context->getScheme()])) { + if (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + $allow[] = 'GET'; + goto not_nonsecure; + } + return $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes)); } return array('_route' => 'nonsecure'); } + not_nonsecure: throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php index 28f65aeeb5..7ea8aa2834 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php @@ -19,6 +19,14 @@ use Symfony\Component\Routing\RequestContext; class DumpedRedirectableUrlMatcherTest extends RedirectableUrlMatcherTest { + /** + * @expectedException \Symfony\Component\Routing\Exception\MethodNotAllowedException + */ + public function testRedirectWhenNoSlashForNonSafeMethod() + { + parent::testRedirectWhenNoSlashForNonSafeMethod(); + } + protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null) { static $i = 0;