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 eaac18b

Browse filesBrowse files
[Routing] don't decode nor double-encode already encoded slashes when generating URLs
1 parent a760037 commit eaac18b
Copy full SHA for eaac18b

File tree

3 files changed

+12
-0
lines changed
Filter options

3 files changed

+12
-0
lines changed

‎src/Symfony/Component/Routing/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.3.0
5+
-----
6+
7+
* already encoded slashes are not decoded nor double-encoded anymore when generating URLs
8+
49
5.2.0
510
-----
611

‎src/Symfony/Component/Routing/Generator/UrlGenerator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Generator/UrlGenerator.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
6666
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
6767
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss
6868
'%2F' => '/',
69+
'%252F' => '%2F',
6970
// the following chars are general delimiters in the URI specification but have only special meaning in the authority component
7071
// so they can safely be used in the path in unencoded form
7172
'%40' => '@',

‎src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,12 @@ public function testEncodingOfRelativePathSegments()
467467
$this->assertSame('/app.php/a./.a/a../..a/...', $this->getGenerator($routes)->generate('test'));
468468
}
469469

470+
public function testEncodingOfSlashInPath()
471+
{
472+
$routes = $this->getRoutes('test', new Route('/dir/{path}/dir2', [], ['path' => '.+']));
473+
$this->assertSame('/app.php/dir/foo/bar%2Fbaz/dir2', $this->getGenerator($routes)->generate('test', ['path' => 'foo/bar%2Fbaz']));
474+
}
475+
470476
public function testAdjacentVariables()
471477
{
472478
$routes = $this->getRoutes('test', new Route('/{x}{y}{z}.{_format}', ['z' => 'default-z', '_format' => 'html'], ['y' => '\d+']));

0 commit comments

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