From 668732305a518fee80a30bad4d6b1eb2d091f716 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 1 Dec 2020 15:29:09 +0100 Subject: [PATCH 1/9] fix lexing backslashes in single quoted strings --- src/Symfony/Component/Yaml/Parser.php | 4 +++- src/Symfony/Component/Yaml/Tests/ParserTest.php | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 56322c387d..20365a6583 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -1170,7 +1170,9 @@ class Parser for (; \strlen($this->currentLine) > $cursor; ++$cursor) { switch ($this->currentLine[$cursor]) { case '\\': - if (isset($this->currentLine[++$cursor])) { + if ("'" === $quotation) { + $value .= '\\'; + } elseif (isset($this->currentLine[++$cursor])) { $value .= '\\'.$this->currentLine[$cursor]; } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index cea3d3f330..bc5332e513 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1618,6 +1618,11 @@ YAML ]; } + public function testBackslashInSingleQuotedString() + { + $this->assertSame(['foo' => 'bar\\'], $this->parser->parse("foo: 'bar\'")); + } + public function testParseMultiLineString() { $this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz")); From b67baa4e7f13ebe2971c925501e6be7a2e2a2e73 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 3 Dec 2020 00:19:14 +0100 Subject: [PATCH 2/9] [HttpFoundation] Ignore stack trace printed by Xdebug 3. --- .../Tests/Fixtures/response-functional/cookie_max_age.expected | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected b/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected index bdb9d023f8..8e17adec03 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected +++ b/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected @@ -1,6 +1,6 @@ Warning: Expiry date cannot have a year greater than 9999 in %scookie_max_age.php on line 10 - +%a Array ( [0] => Content-Type: text/plain; charset=utf-8 From c53a6d04c800ae0493147e902838716787b48dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4dlich?= Date: Fri, 4 Dec 2020 21:45:17 +0100 Subject: [PATCH 3/9] Fix github pr template and include 5.2 for bugfixes --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c113ccbf96..2b27d887c2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ | Q | A | ------------- | --- -| Branch? | 5.x for features / 4.4 or 5.1 for bug fixes +| Branch? | 5.x for features / 4.4, 5.1 or 5.2 for bug fixes | Bug fix? | yes/no | New feature? | yes/no | Deprecations? | yes/no From 4d821d6c3490c648b8c7f35d7cebb60c6d545e78 Mon Sep 17 00:00:00 2001 From: Gert de Pagter Date: Wed, 2 Dec 2020 13:28:13 +0100 Subject: [PATCH 4/9] [HttpClient] throw clearer error when no scheme is provided --- .../Component/HttpClient/HttpClientTrait.php | 4 ++++ .../HttpClient/Tests/HttpClientTraitTest.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 2431e806b0..cf439c6ff0 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -377,6 +377,10 @@ trait HttpClientTrait throw new InvalidArgumentException(sprintf('Invalid "base_uri" option: host or scheme is missing in "%s".', implode('', $base))); } + if (null === $url['scheme'] && (null === $base || null === $base['scheme'])) { + throw new InvalidArgumentException(sprintf('Invalid URL: scheme is missing in "%s". Did you forget to add "http(s)://"?', implode('', $base ?? $url))); + } + if (null === $base && '' === $url['scheme'].$url['authority']) { throw new InvalidArgumentException(sprintf('Invalid URL: no "base_uri" option was provided and host or scheme is missing in "%s".', implode('', $url))); } diff --git a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php index bce71ce823..f3ece3c140 100644 --- a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpClient\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpClient\Exception\InvalidArgumentException; use Symfony\Component\HttpClient\HttpClientTrait; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -120,6 +121,20 @@ class HttpClientTraitTest extends TestCase ]; } + public function testResolveUrlWithoutScheme() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid URL: scheme is missing in "//localhost:8080". Did you forget to add "http(s)://"?'); + self::resolveUrl(self::parseUrl('localhost:8080'), null); + } + + public function testResolveBaseUrlWitoutScheme() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid URL: scheme is missing in "//localhost:8081". Did you forget to add "http(s)://"?'); + self::resolveUrl(self::parseUrl('/foo'), self::parseUrl('localhost:8081')); + } + /** * @dataProvider provideParseUrl */ From fb2ea6f632b0ec75033453b071a70c0d6b18ee55 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 5 Dec 2020 07:27:59 +0100 Subject: [PATCH 5/9] Fix CS --- .../DependencyInjection/Compiler/ExceptionListenerPassTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExceptionListenerPassTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExceptionListenerPassTest.php index cc7558f6e6..673da74f4d 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExceptionListenerPassTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExceptionListenerPassTest.php @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -declare(strict_types=1); - namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; From 67bd779ef4605bb5e8b01e4adb97261064d64471 Mon Sep 17 00:00:00 2001 From: Frank Jogeleit Date: Fri, 4 Dec 2020 19:08:02 +0100 Subject: [PATCH 6/9] =?UTF-8?q?[FrameworkBundle]=20TextDescriptor::formatC?= =?UTF-8?q?ontrollerLink=20checked=20method=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FrameworkBundle/Console/Descriptor/TextDescriptor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index ee5e97c203..a2af0c7949 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -504,7 +504,9 @@ class TextDescriptor extends Descriptor } try { - if (\is_array($controller)) { + if (null === $controller) { + return $anchorText; + } elseif (\is_array($controller)) { $r = new \ReflectionMethod($controller[0], $controller[1]); } elseif ($controller instanceof \Closure) { $r = new \ReflectionFunction($controller); From 9208c69b217fa9ff64933dbd8f891c1fd39b9083 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 3 Dec 2020 00:32:57 +0100 Subject: [PATCH 7/9] [HttpFoundation] Make sure we reuse the current PHP binary for the webserver process in functional tests. --- .../Component/HttpFoundation/Tests/ResponseFunctionalTest.php | 2 +- .../Session/Storage/Handler/AbstractSessionHandlerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php index e94f4defc4..49acff5abc 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php @@ -23,7 +23,7 @@ class ResponseFunctionalTest extends TestCase 1 => ['file', '/dev/null', 'w'], 2 => ['file', '/dev/null', 'w'], ]; - if (!self::$server = @proc_open('exec php -S localhost:8054', $spec, $pipes, __DIR__.'/Fixtures/response-functional')) { + if (!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8054', $spec, $pipes, __DIR__.'/Fixtures/response-functional')) { self::markTestSkipped('PHP server unable to start.'); } sleep(1); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php index 4a045f2ad2..45257abb98 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php @@ -23,7 +23,7 @@ class AbstractSessionHandlerTest extends TestCase 1 => ['file', '/dev/null', 'w'], 2 => ['file', '/dev/null', 'w'], ]; - if (!self::$server = @proc_open('exec php -S localhost:8053', $spec, $pipes, __DIR__.'/Fixtures')) { + if (!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8053', $spec, $pipes, __DIR__.'/Fixtures')) { self::markTestSkipped('PHP server unable to start.'); } sleep(1); From 41a965cdc433603ebbc9363abee4b3394168d42f Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 30 Nov 2020 22:38:34 +0100 Subject: [PATCH 8/9] [Mime] Leverage PHP 8's detection of CSV files. --- src/Symfony/Component/Mime/MimeTypes.php | 3 ++- .../Mime/Tests/Fixtures/mimetypes/abc.csv | 3 +++ src/Symfony/Component/Mime/Tests/MimeTypesTest.php | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Mime/Tests/Fixtures/mimetypes/abc.csv diff --git a/src/Symfony/Component/Mime/MimeTypes.php b/src/Symfony/Component/Mime/MimeTypes.php index 653a36458c..5de599ca9a 100644 --- a/src/Symfony/Component/Mime/MimeTypes.php +++ b/src/Symfony/Component/Mime/MimeTypes.php @@ -166,6 +166,7 @@ final class MimeTypes implements MimeTypesInterface 'application/cdmi-queue' => ['cdmiq'], 'application/cdr' => ['cdr'], 'application/coreldraw' => ['cdr'], + 'application/csv' => ['csv'], 'application/cu-seeme' => ['cu'], 'application/davmount+xml' => ['davmount'], 'application/dbase' => ['dbf'], @@ -1817,7 +1818,7 @@ final class MimeTypes implements MimeTypesInterface 'csp' => ['application/vnd.commonspace'], 'css' => ['text/css'], 'cst' => ['application/x-director'], - 'csv' => ['text/csv', 'text/x-comma-separated-values', 'text/x-csv'], + 'csv' => ['text/csv', 'text/x-comma-separated-values', 'text/x-csv', 'application/csv'], 'csvs' => ['text/csv-schema'], 'cu' => ['application/cu-seeme'], 'cue' => ['application/x-cue'], diff --git a/src/Symfony/Component/Mime/Tests/Fixtures/mimetypes/abc.csv b/src/Symfony/Component/Mime/Tests/Fixtures/mimetypes/abc.csv new file mode 100644 index 0000000000..bd1221bfdd --- /dev/null +++ b/src/Symfony/Component/Mime/Tests/Fixtures/mimetypes/abc.csv @@ -0,0 +1,3 @@ +a,b,c +d,e,f +g,h,i diff --git a/src/Symfony/Component/Mime/Tests/MimeTypesTest.php b/src/Symfony/Component/Mime/Tests/MimeTypesTest.php index b1387c9a5c..9b16ff6807 100644 --- a/src/Symfony/Component/Mime/Tests/MimeTypesTest.php +++ b/src/Symfony/Component/Mime/Tests/MimeTypesTest.php @@ -73,4 +73,18 @@ class MimeTypesTest extends AbstractMimeTypeGuesserTest $this->assertContains('text/baz', $mt->getMimeTypes('foo')); $this->assertSame(['foo', 'moof'], $mt->getExtensions('text/baz')); } + + /** + * PHP 8 detects .csv files as "application/csv" while PHP 7 returns "text/plain". + * + * @requires PHP 8 + */ + public function testCsvExtension() + { + $mt = new MimeTypes(); + + $mime = $mt->guessMimeType(__DIR__.'/Fixtures/mimetypes/abc.csv'); + $this->assertSame('application/csv', $mime); + $this->assertSame(['csv'], $mt->getExtensions($mime)); + } } From cf94f2a5919f58d049be35392242aa3dc657f66d Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 5 Dec 2020 09:52:36 +0100 Subject: [PATCH 9/9] [HttpFoundation] Make test pass without Xdebug. --- .../Tests/Fixtures/response-functional/cookie_max_age.expected | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected b/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected index 8e17adec03..6870a27728 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected +++ b/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected @@ -1,6 +1,6 @@ Warning: Expiry date cannot have a year greater than 9999 in %scookie_max_age.php on line 10 -%a +%A Array ( [0] => Content-Type: text/plain; charset=utf-8