From 72684b001c24317fab602215b676661b4945eb11 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 3 Oct 2019 17:45:25 +0200 Subject: [PATCH 1/6] [Validator] Fix ValidValidator group cascading usage --- src/Symfony/Component/Validator/Constraints/ValidValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Constraints/ValidValidator.php b/src/Symfony/Component/Validator/Constraints/ValidValidator.php index cc10ec5204..695ec82254 100644 --- a/src/Symfony/Component/Validator/Constraints/ValidValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ValidValidator.php @@ -33,6 +33,6 @@ class ValidValidator extends ConstraintValidator $this->context ->getValidator() ->inContext($this->context) - ->validate($value, null, [$this->context->getGroup()]); + ->validate($value, null, $this->context->getGroup()); } } From 4d5530f8a4a5ccd480bac3c33d0c9f2f201e64c8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 4 Oct 2019 22:55:59 +0200 Subject: [PATCH 2/6] [Routing] gracefully handle docref_root ini setting --- .../Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php | 4 ++-- .../Routing/Matcher/Dumper/StaticPrefixCollection.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php index 51cb046b33..ab67e6885a 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php @@ -91,7 +91,7 @@ EOF; while (true) { try { - $this->signalingException = new \RuntimeException('preg_match(): Compilation failed: regular expression is too large'); + $this->signalingException = new \RuntimeException('Compilation failed: regular expression is too large'); $compiledRoutes = array_merge($compiledRoutes, $this->compileDynamicRoutes($dynamicRoutes, $matchHost, $chunkLimit, $conditions)); break; @@ -349,7 +349,7 @@ EOF; $state->markTail = 0; // if the regex is too large, throw a signaling exception to recompute with smaller chunk size - set_error_handler(function ($type, $message) { throw 0 === strpos($message, $this->signalingException->getMessage()) ? $this->signalingException : new \ErrorException($message); }); + set_error_handler(function ($type, $message) { throw false !== strpos($message, $this->signalingException->getMessage()) ? $this->signalingException : new \ErrorException($message); }); try { preg_match($state->regex, ''); } finally { diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php index 50f974f2e8..65b6c0718b 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php @@ -197,6 +197,6 @@ class StaticPrefixCollection public static function handleError($type, $msg) { - return 0 === strpos($msg, 'preg_match(): Compilation failed: lookbehind assertion is not fixed length'); + return false !== strpos($msg, 'Compilation failed: lookbehind assertion is not fixed length'); } } From 2315be85d8e9c063d90dd4f8c5f6dddb016ab843 Mon Sep 17 00:00:00 2001 From: Atthaphon Urairat Date: Fri, 4 Oct 2019 16:41:22 +0700 Subject: [PATCH 3/6] [Validator] Add the missing translations for the Thai (\"th\") locale --- .../Resources/translations/validators.th.xlf | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf index 63ce95ab1b..31aa00cfac 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf @@ -204,7 +204,7 @@ This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - คอเล็กชั่นนี้ควรจะประกอบไปด้วยอ่างน้อย {{ limit }} สมาชิก + คอเล็กชั่นนี้ควรจะประกอบไปด้วยอย่างน้อย {{ limit }} สมาชิก This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. @@ -298,6 +298,74 @@ The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed. ภาพนี้เป็นแนวตั้ง ({{ width }}x{{ height }}px) ไม่อนุญาตภาพที่เป็นแนวตั้ง + + An empty file is not allowed. + ไม่อนุญาตให้ใช้ไฟล์ว่าง + + + The host could not be resolved. + ไม่สามารถแก้ไขชื่อโฮสต์ + + + This value does not match the expected {{ charset }} charset. + ค่านี้ไม่ตรงกับการเข้ารหัส {{ charset }} + + + This is not a valid Business Identifier Code (BIC). + นี่ไม่ถูกต้องตามรหัสสำหรับระบุธุรกิจนี้ (BIC) + + + Error + เกิดข้อผิดพลาด + + + This is not a valid UUID. + นี่ไม่ใช่ UUID ที่ถูกต้อง + + + This value should be a multiple of {{ compared_value }}. + ค่านี้ควรเป็น {{ compared_value }} หลายตัว + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + รหัสสำหรับระบุธุรกิจนี้ (BIC) ไม่เกี่ยวข้องกับ IBAN {{ iban }} + + + This value should be valid JSON. + ค่านี้ควรอยู่ในรูปแบบ JSON ที่ถูกต้อง + + + This collection should contain only unique elements. + คอเล็กชั่นนี้ควรมีเฉพาะสมาชิกที่ไม่ซ้ำกันเท่านั้น + + + This value should be positive. + ค่านี้ควรเป็นค่าบวก + + + This value should be either positive or zero. + ค่านี้ควรเป็นค่าบวกหรือค่าศูนย์ + + + This value should be negative. + ค่านี้ควรเป็นค่าลบ + + + This value should be either negative or zero. + ค่านี้ควรเป็นค่าลบหรือค่าศูนย์ + + + This value is not a valid timezone. + ค่าเขตเวลาไม่ถูกต้อง + + + This password has been leaked in a data breach, it must not be used. Please use another password. + รหัสผ่านนี้ได้เคยรั่วไหลออกไปโดยถูกการละเมิดข้อมูล ซึ่งไม่ควรนำกลับมาใช้ กรุณาใช้รหัสผ่านอื่น + + + This value should be between {{ min }} and {{ max }}. + ค่านี้ควรอยู่ระหว่าง {{ min }} ถึง {{ max }} + From a84e4e021a31fdd125848552adbba1a6afc3c8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Sun, 6 Oct 2019 21:52:09 +0200 Subject: [PATCH 4/6] Remove useless testCanCheckIfTerminalIsInteractive test case --- .../Component/Console/Tests/ApplicationTest.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index c7e8495265..d61418f37b 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -1587,23 +1587,6 @@ class ApplicationTest extends TestCase $this->assertStringContainsString('The foo:bar command', $tester->getDisplay()); } - /** - * @requires function posix_isatty - */ - public function testCanCheckIfTerminalIsInteractive() - { - $application = new CustomDefaultCommandApplication(); - $application->setAutoExit(false); - - $tester = new ApplicationTester($application); - $tester->run(['command' => 'help']); - - $this->assertFalse($tester->getInput()->hasParameterOption(['--no-interaction', '-n'])); - - $inputStream = $tester->getInput()->getStream(); - $this->assertEquals($tester->getInput()->isInteractive(), @posix_isatty($inputStream)); - } - public function testRunLazyCommandService() { $container = new ContainerBuilder(); From 5cd8895c67c74660cd87501ce30168600793d315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Jusi=C4=99ga?= Date: Sat, 5 Oct 2019 20:51:52 +0200 Subject: [PATCH 5/6] [HttpClient] bugfix exploding values of headers --- .../HttpClient/CachingHttpClient.php | 11 +++-- .../Component/HttpClient/HttpClientTrait.php | 11 +++++ .../Tests/CachingHttpClientTest.php | 42 +++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 src/Symfony/Component/HttpClient/Tests/CachingHttpClientTest.php diff --git a/src/Symfony/Component/HttpClient/CachingHttpClient.php b/src/Symfony/Component/HttpClient/CachingHttpClient.php index 65426ef647..5eab049732 100644 --- a/src/Symfony/Component/HttpClient/CachingHttpClient.php +++ b/src/Symfony/Component/HttpClient/CachingHttpClient.php @@ -77,17 +77,20 @@ class CachingHttpClient implements HttpClientInterface $request = Request::create($url, $method); $request->attributes->set('http_client_options', $options); - foreach ($options['headers'] as $name => $values) { + foreach ($options['normalized_headers'] as $name => $values) { if ('cookie' !== $name) { - $request->headers->set($name, $values); + foreach ($values as $value) { + $request->headers->set($name, substr($value, 2 + \strlen($name)), false); + } + continue; } foreach ($values as $cookies) { - foreach (explode('; ', $cookies) as $cookie) { + foreach (explode('; ', substr($cookies, \strlen('Cookie: '))) as $cookie) { if ('' !== $cookie) { $cookie = explode('=', $cookie, 2); - $request->cookies->set($cookie[0], $cookie[1] ?? null); + $request->cookies->set($cookie[0], $cookie[1] ?? ''); } } } diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 9fc37f7299..3fd9814df6 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -196,10 +196,21 @@ trait HttpClientTrait $normalizedHeaders = []; foreach ($headers as $name => $values) { + if (\is_object($values) && method_exists('__toString')) { + $values = (string) $values; + } + if (\is_int($name)) { + if (!\is_string($values)) { + throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, %s given.', $name, \gettype($values))); + } [$name, $values] = explode(':', $values, 2); $values = [ltrim($values)]; } elseif (!is_iterable($values)) { + if (\is_object($values)) { + throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, %s given.', $name, \get_class($values))); + } + $values = (array) $values; } diff --git a/src/Symfony/Component/HttpClient/Tests/CachingHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/CachingHttpClientTest.php new file mode 100644 index 0000000000..4d1ca6de17 --- /dev/null +++ b/src/Symfony/Component/HttpClient/Tests/CachingHttpClientTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpClient\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpClient\CachingHttpClient; +use Symfony\Component\HttpClient\MockHttpClient; +use Symfony\Component\HttpClient\Response\MockResponse; +use Symfony\Component\HttpKernel\HttpCache\Store; + +class CachingHttpClientTest extends TestCase +{ + public function testRequestHeaders() + { + $options = [ + 'headers' => [ + 'Application-Name' => 'test1234', + 'Test-Name-Header' => 'test12345', + ], + ]; + + $mockClient = new MockHttpClient(); + $store = new Store(sys_get_temp_dir().'/sf_http_cache'); + $client = new CachingHttpClient($mockClient, $store, $options); + + $response = $client->request('GET', 'http://example.com/foo-bar'); + + rmdir(sys_get_temp_dir().'/sf_http_cache'); + self::assertInstanceOf(MockResponse::class, $response); + self::assertSame($response->getRequestOptions()['normalized_headers']['application-name'][0], 'Application-Name: test1234'); + self::assertSame($response->getRequestOptions()['normalized_headers']['test-name-header'][0], 'Test-Name-Header: test12345'); + } +} From 0272b8d341721c717861ef949cb20ecfac18603e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 7 Oct 2019 14:36:18 +0200 Subject: [PATCH 6/6] [travis] Fix build-packages script --- .github/build-packages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/build-packages.php b/.github/build-packages.php index 1f59c35276..d859e3ec80 100644 --- a/.github/build-packages.php +++ b/.github/build-packages.php @@ -47,7 +47,7 @@ foreach ($dirs as $k => $dir) { if (isset($preferredInstall[$package->name]) && 'source' === $preferredInstall[$package->name]) { passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *"); } else { - passthru("cd $dir && git init && git add . && git commit -m - && git archive -o package.tar HEAD && rm .git/ -Rf"); + passthru("cd $dir && git init && git add . && git commit --author \"Symfony <>\" -m - && git archive -o package.tar HEAD && rm .git/ -Rf"); } if (!isset($package->extra->{'branch-alias'}->{'dev-master'})) {