@@ -75,11 +75,6 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
75
75
'%7C ' => '| ' ,
76
76
);
77
77
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
-
83
78
/**
84
79
* Constructor.
85
80
*
@@ -187,21 +182,19 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
187
182
188
183
if ('' === $ url ) {
189
184
$ url = '/ ' ;
190
- } else if (preg_match ($ this ->urlEncodingSkipRegexp , $ url )) {
191
- // the contexts base URL is already encoded (see Symfony\Component\HttpFoundation\Request)
192
- $ url = strtr (rawurlencode ($ url ), $ this ->decodedChars );
193
185
}
194
186
187
+ // the contexts base URL is already encoded (see Symfony\Component\HttpFoundation\Request)
188
+ $ url = strtr (rawurlencode ($ url ), $ this ->decodedChars );
189
+
195
190
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
196
191
// so we need to encode them as they are not used for this purpose here
197
192
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
198
- if (false !== strpos ($ url , '/. ' )) {
199
- $ url = strtr ($ url , array ('/../ ' => '/%2E%2E/ ' , '/./ ' => '/%2E/ ' ));
200
- if ('/.. ' === substr ($ url , -3 )) {
201
- $ url = substr ($ url , 0 , -2 ).'%2E%2E ' ;
202
- } elseif ('/. ' === substr ($ url , -2 )) {
203
- $ url = substr ($ url , 0 , -1 ).'%2E ' ;
204
- }
193
+ $ url = strtr ($ url , array ('/../ ' => '/%2E%2E/ ' , '/./ ' => '/%2E/ ' ));
194
+ if ('/.. ' === substr ($ url , -3 )) {
195
+ $ url = substr ($ url , 0 , -2 ).'%2E%2E ' ;
196
+ } elseif ('/. ' === substr ($ url , -2 )) {
197
+ $ url = substr ($ url , 0 , -1 ).'%2E ' ;
205
198
}
206
199
207
200
$ schemeAuthority = '' ;
@@ -278,7 +271,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
278
271
if ($ extra && $ query = http_build_query ($ extra , '' , '& ' )) {
279
272
// "/" and "?" can be left decoded for better user experience, see
280
273
// http://tools.ietf.org/html/rfc3986#section-3.4
281
- $ url .= '? ' .( false === strpos ( $ query , ' %2F ' ) ? $ query : strtr ($ query , array ('%2F ' => '/ ' ) ));
274
+ $ url .= '? ' .strtr ($ query , array ('%2F ' => '/ ' ));
282
275
}
283
276
284
277
return $ url ;
0 commit comments