Skip to content

Commit 0d814e0

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: add @event annotation for AuthenticationEvents add @event annotation for KernelEvents bumped Symfony version to 2.7.13 updated VERSION for 2.7.12 update CONTRIBUTORS for 2.7.12 updated CHANGELOG for 2.7.12 bumped Symfony version to 2.3.41 updated VERSION for 2.3.40 update CONTRIBUTORS for 2.3.40 updated CHANGELOG for 2.3.40 Revert "minor #18257 [Routing] Don't needlessly execute strtr's as they are fairly expensive (arjenm)" Revert "fixed CS" [FrameworkBundle] Remove misleading comment bug #17460 [DI] fix ambiguous services schema
2 parents 0a1222c + 07c44ac commit 0d814e0

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

Generator/UrlGenerator.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
7575
'%7C' => '|',
7676
);
7777

78-
/**
79-
* @var string This regexp matches all characters that are not or should not be encoded by rawurlencode (see list in array above).
80-
*/
81-
private $urlEncodingSkipRegexp = '#[^-.~a-zA-Z0-9_/@:;,=+!*|]#';
82-
8378
/**
8479
* Constructor.
8580
*
@@ -201,21 +196,19 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
201196

202197
if ('' === $url) {
203198
$url = '/';
204-
} elseif (preg_match($this->urlEncodingSkipRegexp, $url)) {
205-
// the context base URL is already encoded (see Symfony\Component\HttpFoundation\Request)
206-
$url = strtr(rawurlencode($url), $this->decodedChars);
207199
}
208200

201+
// the contexts base URL is already encoded (see Symfony\Component\HttpFoundation\Request)
202+
$url = strtr(rawurlencode($url), $this->decodedChars);
203+
209204
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
210205
// so we need to encode them as they are not used for this purpose here
211206
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
212-
if (false !== strpos($url, '/.')) {
213-
$url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
214-
if ('/..' === substr($url, -3)) {
215-
$url = substr($url, 0, -2).'%2E%2E';
216-
} elseif ('/.' === substr($url, -2)) {
217-
$url = substr($url, 0, -1).'%2E';
218-
}
207+
$url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
208+
if ('/..' === substr($url, -3)) {
209+
$url = substr($url, 0, -2).'%2E%2E';
210+
} elseif ('/.' === substr($url, -2)) {
211+
$url = substr($url, 0, -1).'%2E';
219212
}
220213

221214
$schemeAuthority = '';
@@ -292,7 +285,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
292285
if ($extra && $query = http_build_query($extra, '', '&')) {
293286
// "/" and "?" can be left decoded for better user experience, see
294287
// http://tools.ietf.org/html/rfc3986#section-3.4
295-
$url .= '?'.(false === strpos($query, '%2F') ? $query : strtr($query, array('%2F' => '/')));
288+
$url .= '?'.strtr($query, array('%2F' => '/'));
296289
}
297290

298291
return $url;

0 commit comments

Comments
 (0)