From 6ecae5719c92164aeb5a7eaeb0bc1d1a1fe0b149 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 7 Dec 2020 12:54:17 +0100 Subject: [PATCH 1/3] [FrameworkBundle] fix preserving some special chars in the query string when redirecting --- .../FrameworkBundle/Controller/RedirectController.php | 2 +- .../Tests/Controller/RedirectControllerTest.php | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index 1be9f99f23..bbbdd9b1dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -212,7 +212,7 @@ class RedirectController if (false === $i = strpos($k, '[')) { $q[] = bin2hex($k).$v; } else { - $q[] = substr_replace($k, bin2hex(substr($k, 0, $i)), 0, $i).$v; + $q[] = bin2hex(substr($k, 0, $i)).rawurlencode(substr($k, $i)).$v; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index 732ac3e2d6..f053af3fa4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -302,16 +302,19 @@ class RedirectControllerTest extends TestCase $baseUrl = '/base'; $port = 80; - $request = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza'); + $request = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza&f[%2525][%26][%3D][p.c]=d'); $request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]); $urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); - $urlGenerator->expects($this->exactly(2))->method('generate')->willReturn('/test?b.se=zaza&base2=zaza')->with('/test', ['b.se' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL); + $urlGenerator->expects($this->exactly(2)) + ->method('generate') + ->willReturn('/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d') + ->with('/test', ['b.se' => 'zaza', 'base2' => 'zaza', 'f' => ['%25' => ['&' => ['=' => ['p.c' => 'd']]]]], UrlGeneratorInterface::ABSOLUTE_URL); $controller = new RedirectController($urlGenerator); - $this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?b.se=zaza&base2=zaza'); + $this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d'); $request->attributes->set('_route_params', ['base2' => 'zaza', 'route' => '/test', 'ignoreAttributes' => false, 'keepRequestMethod' => false, 'keepQueryParams' => true]); - $this->assertRedirectUrl($controller($request), '/test?b.se=zaza&base2=zaza'); + $this->assertRedirectUrl($controller($request), '/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d'); } public function testRedirectWithQueryWithRouteParamsOveriding() From 745020892f1d6f38ab2cbf89b0120995050af9d7 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 7 Dec 2020 20:06:38 +0000 Subject: [PATCH 2/3] Run intl-data tests on resources change --- .github/workflows/intl-data-tests.yml | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/intl-data-tests.yml diff --git a/.github/workflows/intl-data-tests.yml b/.github/workflows/intl-data-tests.yml new file mode 100644 index 0000000000..17e26dad0d --- /dev/null +++ b/.github/workflows/intl-data-tests.yml @@ -0,0 +1,47 @@ +name: Intl data tests + +on: + push: + paths: + - 'src/Symfony/Component/Intl/Resources/data/**' + pull_request: + paths: + - 'src/Symfony/Component/Intl/Resources/data/**' + +jobs: + + tests: + name: Tests (intl-data) + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Define the ICU version + run: | + SYMFONY_ICU_VERSION=$(php -r 'require "src/Symfony/Component/Intl/Intl.php"; echo Symfony\Component\Intl\Intl::getIcuStubVersion();') + echo "SYMFONY_ICU_VERSION=$SYMFONY_ICU_VERSION" >> $GITHUB_ENV + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + coverage: "none" + extensions: "zip,intl-${{env.SYMFONY_ICU_VERSION}}" + ini-values: "memory_limit=-1" + php-version: "7.4" + + - name: Install dependencies + run: | + echo "::group::composer update" + composer update --no-progress --no-suggest --ansi + echo "::endgroup::" + echo "::group::install phpunit" + ./phpunit install + echo "::endgroup::" + + - name: Report the ICU version + run: icu-config --version && php -i | grep 'ICU version' + + - name: Run intl-data tests + run: ./phpunit --group intl-data -v From 67277e55f0da45c0d52e0c84f31f74c87d50e7b1 Mon Sep 17 00:00:00 2001 From: vudaltsov Date: Sat, 5 Dec 2020 21:35:32 +0300 Subject: [PATCH 3/3] [Serializer] Fixed serialize and denormalize return types --- .../Component/Serializer/Normalizer/DenormalizerInterface.php | 2 +- src/Symfony/Component/Serializer/SerializerInterface.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php index 337fe2e8c2..d903b3912d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php @@ -32,7 +32,7 @@ interface DenormalizerInterface * @param string $format Format the given data was extracted from * @param array $context Options available to the denormalizer * - * @return object|array + * @return mixed * * @throws BadMethodCallException Occurs when the normalizer is not called in an expected context * @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported diff --git a/src/Symfony/Component/Serializer/SerializerInterface.php b/src/Symfony/Component/Serializer/SerializerInterface.php index f67dd66edd..96e144e90e 100644 --- a/src/Symfony/Component/Serializer/SerializerInterface.php +++ b/src/Symfony/Component/Serializer/SerializerInterface.php @@ -32,7 +32,7 @@ interface SerializerInterface * * @param mixed $data * - * @return object|array + * @return mixed */ public function deserialize($data, string $type, string $format, array $context = []); }