From d4e2cec1fbeabf0ed321bc56fcb9b84ffae05afa Mon Sep 17 00:00:00 2001 From: Randy Geraads Date: Thu, 6 Aug 2020 15:14:23 +0200 Subject: [PATCH] Fix #37740: Cast all Request parameter values to string --- src/Symfony/Component/BrowserKit/Request.php | 5 +++++ .../BrowserKit/Tests/RequestTest.php | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/Symfony/Component/BrowserKit/Request.php b/src/Symfony/Component/BrowserKit/Request.php index 4dd0bc406f8cf..c2eeba8ee4f4a 100644 --- a/src/Symfony/Component/BrowserKit/Request.php +++ b/src/Symfony/Component/BrowserKit/Request.php @@ -37,6 +37,11 @@ public function __construct(string $uri, string $method, array $parameters = [], { $this->uri = $uri; $this->method = $method; + + array_walk_recursive($parameters, static function (&$value) { + $value = (string) $value; + }); + $this->parameters = $parameters; $this->files = $files; $this->cookies = $cookies; diff --git a/src/Symfony/Component/BrowserKit/Tests/RequestTest.php b/src/Symfony/Component/BrowserKit/Tests/RequestTest.php index e7718eef87ad6..5d7c7d6b894d3 100644 --- a/src/Symfony/Component/BrowserKit/Tests/RequestTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/RequestTest.php @@ -51,4 +51,24 @@ public function testGetServer() $request = new Request('http://www.example.com/', 'get', [], [], [], ['foo' => 'bar']); $this->assertEquals(['foo' => 'bar'], $request->getServer(), '->getServer() returns the server parameters of the request'); } + + public function testAllParameterValuesAreConvertedToString(): void + { + $parameters = [ + 'foo' => 1, + 'bar' => [ + 'baz' => 2, + ], + ]; + + $expected = [ + 'foo' => '1', + 'bar' => [ + 'baz' => '2', + ], + ]; + + $request = new Request('http://www.example.com/', 'get', $parameters); + $this->assertSame($expected, $request->getParameters()); + } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy