bug #39357 [FrameworkBundle] fix preserving some special chars in the query string (nicolas-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[FrameworkBundle] fix preserving some special chars in the query string
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #39307
| License | MIT
| Doc PR | -
Commits
-------
6ecae5719c
[FrameworkBundle] fix preserving some special chars in the query string when redirecting
This commit is contained in:
commit
a630685da1
@ -212,7 +212,7 @@ class RedirectController
|
|||||||
if (false === $i = strpos($k, '[')) {
|
if (false === $i = strpos($k, '[')) {
|
||||||
$q[] = bin2hex($k).$v;
|
$q[] = bin2hex($k).$v;
|
||||||
} else {
|
} else {
|
||||||
$q[] = substr_replace($k, bin2hex(substr($k, 0, $i)), 0, $i).$v;
|
$q[] = bin2hex(substr($k, 0, $i)).rawurlencode(substr($k, $i)).$v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,16 +302,19 @@ class RedirectControllerTest extends TestCase
|
|||||||
$baseUrl = '/base';
|
$baseUrl = '/base';
|
||||||
$port = 80;
|
$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']]);
|
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
|
||||||
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
|
$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);
|
$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]);
|
$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()
|
public function testRedirectWithQueryWithRouteParamsOveriding()
|
||||||
|
Reference in New Issue
Block a user