8000 [Routing] Replace previously added preg_match with preg_replace_callback by arjenm · Pull Request #18424 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] Replace previously added preg_match with preg_replace_callback #18424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Routing] Replace previously added preg_match with preg_replace_callb…
…ack, fix code comments
  • Loading branch information
arjenm committed Apr 17, 2016
commit 3dbd6af3e2795b7b3a229440f48a76c03ab1b4d7
10 changes: 4 additions & 6 deletions src/Symfony/Component/Routing/Generator/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface
{
/**
* This regexp matches all characters that should be percent encoded in paths for url's generated by this class.
* This regexp matches all characters that should be percent encoded in paths for URLs generated by this class.
*
* PHP's rawurlencode() encodes all chars except "a-zA-Z0-9-._~" according to RFC 3986. But we want to allow some chars
* to be used in their literal form (reasons below). Other chars inside the path must of course be encoded, e.g.
Expand All @@ -45,11 +45,11 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
* so URI producing applications can use these chars to delimit subcomponents in a path segment without being encoded for better readability.
*
* The regexp is an inverse of the characters above. It allows to only call rawurlencode() for specific charaters,
* thus optimizing scenario's where there are no or very few such characters in urls.
* thus optimizing scenarios where there are no or very few such characters in URLs.
*
* @internal
*/
const PATH_UNSAFE_CHARACTER_REGEXP = '#[^-.~a-zA-Z0-9_/@:;,=+!*|]+#';
const PATH_UNSAFE_CHARACTER_REGEXP = '#[^-.~a-zA-Z0-9_/@:;,=+!*|]++#';

/**
* @var RouteCollection
Expand All @@ -74,7 +74,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
/**
* This array used to define the characters (besides alphanumeric ones) that will not be percent-encoded in the path segment of the generated URL.
*
* @deprecated This array should not be used anymore. Changing it can result in url's that are incompatible with Symfony's url-matching, browsers and/or server software.
* @deprecated since version 3.1, to be removed in 4.0.
*/
protected $decodedChars = array();

Expand Down Expand Up @@ -186,8 +186,6 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
if ('' === $url) {
$url = '/';
} elseif (!empty($this->decodedChars)) {
// Support old style of character replacement, for when someone changed the decodedChars-array,
// its both slower and unsafe, so it'll be removed in the future.
@trigger_error('The class variable '.__CLASS__.'::$decodedChars is deprecated since version 3.1 and will be removed in 4.0.', E_USER_DEPRECATED);
$url = strtr(rawurlencode($url), $this->decodedChars);
} else {
Expand Down
0