Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a630685

Browse filesBrowse files
committed
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 ------- 6ecae57 [FrameworkBundle] fix preserving some special chars in the query string when redirecting
2 parents 7668a1e + 6ecae57 commit a630685
Copy full SHA for a630685

File tree

Expand file treeCollapse file tree

2 files changed

+8
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-5
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private static function parseQuery(string $query)
212212
if (false === $i = strpos($k, '[')) {
213213
$q[] = bin2hex($k).$v;
214214
} else {
215-
$q[] = substr_replace($k, bin2hex(substr($k, 0, $i)), 0, $i).$v;
215+
$q[] = bin2hex(substr($k, 0, $i)).rawurlencode(substr($k, $i)).$v;
216216
}
217217
}
218218

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,19 @@ public function testRedirectWithQuery()
302302
$baseUrl = '/base';
303303
$port = 80;
304304

305-
$request = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza');
305+
$request = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza&f[%2525][%26][%3D][p.c]=d');
306306
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
307307
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
308-
$urlGenerator->expects($this->exactly(2))->method('generate')->willReturn('/test?b.se=zaza&base2=zaza')->with('/test', ['b.se' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL);
308+
$urlGenerator->expects($this->exactly(2))
309+
->method('generate')
310+
->willReturn('/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d')
311+
->with('/test', ['b.se' => 'zaza', 'base2' => 'zaza', 'f' => ['%25' => ['&' => ['=' => ['p.c' => 'd']]]]], UrlGeneratorInterface::ABSOLUTE_URL);
309312

310313
$controller = new RedirectController($urlGenerator);
311-
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?b.se=zaza&base2=zaza');
314+
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d');
312315

313316
$request->attributes->set('_route_params', ['base2' => 'zaza', 'route' => '/test', 'ignoreAttributes' => false, 'keepRequestMethod' => false, 'keepQueryParams' => true]);
314-
$this->assertRedirectUrl($controller($request), '/test?b.se=zaza&base2=zaza');
317+
$this->assertRedirectUrl($controller($request), '/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d');
315318
}
316319

317320
public function testRedirectWithQueryWithRouteParamsOveriding()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.