bug #37270 [FrameworkBundle] preserve dots in query-string when redirecting (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[FrameworkBundle] preserve dots in query-string when redirecting
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #29664
| License | MIT
| Doc PR | -
Commits
-------
fcc0e2c143
[FrameworkBundle] preserve dots in query-string when redirecting
This commit is contained in:
commit
c16bb52252
@ -128,8 +128,7 @@ class RedirectController implements ContainerAwareInterface
|
||||
$scheme = $request->getScheme();
|
||||
}
|
||||
|
||||
$qs = $request->getQueryString();
|
||||
if ($qs) {
|
||||
if ($qs = $request->server->get('QUERY_STRING') ?: $request->getQueryString()) {
|
||||
if (false === strpos($path, '?')) {
|
||||
$qs = '?'.$qs;
|
||||
} else {
|
||||
|
@ -220,9 +220,9 @@ class RedirectControllerTest extends TestCase
|
||||
return [
|
||||
['http://www.example.com/base/redirect-path', '/redirect-path', ''],
|
||||
['http://www.example.com/base/redirect-path?foo=bar', '/redirect-path?foo=bar', ''],
|
||||
['http://www.example.com/base/redirect-path?foo=bar', '/redirect-path', 'foo=bar'],
|
||||
['http://www.example.com/base/redirect-path?foo=bar&abc=example', '/redirect-path?foo=bar', 'abc=example'],
|
||||
['http://www.example.com/base/redirect-path?foo=bar&abc=example&baz=def', '/redirect-path?foo=bar', 'abc=example&baz=def'],
|
||||
['http://www.example.com/base/redirect-path?f.o=bar', '/redirect-path', 'f.o=bar'],
|
||||
['http://www.example.com/base/redirect-path?f.o=bar&a.c=example', '/redirect-path?f.o=bar', 'a.c=example'],
|
||||
['http://www.example.com/base/redirect-path?f.o=bar&a.c=example&b.z=def', '/redirect-path?f.o=bar', 'a.c=example&b.z=def'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -246,29 +246,20 @@ class RedirectControllerTest extends TestCase
|
||||
|
||||
private function createRequestObject($scheme, $host, $port, $baseUrl, $queryString = '')
|
||||
{
|
||||
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getScheme')
|
||||
->willReturn($scheme);
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getHost')
|
||||
->willReturn($host);
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getPort')
|
||||
->willReturn($port);
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getBaseUrl')
|
||||
->willReturn($baseUrl);
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getQueryString')
|
||||
->willReturn($queryString);
|
||||
if ('' !== $queryString) {
|
||||
parse_str($queryString, $query);
|
||||
} else {
|
||||
$query = [];
|
||||
}
|
||||
|
||||
return $request;
|
||||
return new Request($query, [], [], [], [], [
|
||||
'HTTPS' => 'https' === $scheme,
|
||||
'HTTP_HOST' => $host.($port ? ':'.$port : ''),
|
||||
'SERVER_PORT' => $port,
|
||||
'SCRIPT_FILENAME' => $baseUrl,
|
||||
'REQUEST_URI' => $baseUrl,
|
||||
'QUERY_STRING' => $queryString,
|
||||
]);
|
||||
}
|
||||
|
||||
private function createRedirectController($httpPort = null, $httpsPort = null)
|
||||
|
Reference in New Issue
Block a user