Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection][HttpClient][Routing] Reject vertical tab in URIs #59511

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
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): mixed
if (('\\' !== \DIRECTORY_SEPARATOR || 'file' !== $params['scheme']) && false !== ($i = strpos($env, '\\')) && $i < strcspn($env, '?#')) {
throw new RuntimeException(\sprintf('Invalid URL in env var "%s": backslashes are not allowed.', $name));
}
if (\ord($env[0]) <= 32 || \ord($env[-1]) <= 32 || \strlen($env) !== strcspn($env, "\r\n\t")) {
if (\ord($env[0]) <= 32 || \ord($env[-1]) <= 32 || \strlen($env) !== strcspn($env, "\r\n\t\v")) {
throw new RuntimeException(\sprintf('Invalid URL in env var "%s": leading/trailing ASCII control characters or whitespaces are not allowed.', $name));
}
$params += [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ public static function provideGetEnvUrlPath()
* ["a\rb"]
* ["a\nb"]
* ["a\tb"]
* ["a\u000bb"]
* ["\u0000foo"]
* ["foo\u0000"]
* [" foo"]
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/HttpClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ private static function parseUrl(string $url, array $query = [], array $allowedS
if (false !== ($i = strpos($url, '\\')) && $i < strcspn($url, '?#')) {
throw new InvalidArgumentException(\sprintf('Malformed URL "%s": backslashes are not allowed.', $url));
}
if (\strlen($url) !== strcspn($url, "\r\n\t")) {
if (\strlen($url) !== strcspn($url, "\r\n\t\v")) {
throw new InvalidArgumentException(\sprintf('Malformed URL "%s": CR/LF/TAB characters are not allowed.', $url));
}
if ('' !== $url && (\ord($url[0]) <= 32 || \ord($url[-1]) <= 32)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public function testResolveBaseUrlWithoutScheme()
* ["a\rb"]
* ["a\nb"]
* ["a\tb"]
* ["a\u000bb"]
* ["\u0000foo"]
* ["foo\u0000"]
* [" foo"]
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/RequestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function fromUri(string $uri, string $host = 'localhost', string $
if (false !== ($i = strpos($uri, '\\')) && $i < strcspn($uri, '?#')) {
$uri = '';
}
if ('' !== $uri && (\ord($uri[0]) <= 32 || \ord($uri[-1]) <= 32 || \strlen($uri) !== strcspn($uri, "\r\n\t"))) {
if ('' !== $uri && (\ord($uri[0]) <= 32 || \ord($uri[-1]) <= 32 || \strlen($uri) !== strcspn($uri, "\r\n\t\v"))) {
$uri = '';
}

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Routing/Tests/RequestContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public function testFromUriBeingEmpty()
* ["a\rb"]
* ["a\nb"]
* ["a\tb"]
* ["a\u000bb"]
* ["\u0000foo"]
* ["foo\u0000"]
* [" foo"]
Expand Down
Loading