-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Url::ensureScheme does not work in some cases #17191
Comments
|
Interesting, because even though public static function ensureScheme($url, $scheme)
{
if (static::isRelative($url) || !is_string($scheme)) {
return $url;
}
if (substr($url, 0, 2) === '//') {
// e.g. //example.com/path/to/resource
return $scheme === '' ? $url : "$scheme:$url";
}
if (($pos = strpos($url, '://')) !== false) {
if ($scheme === '') {
$url = substr($url, $pos + 1);
} else {
$url = $scheme . substr($url, $pos);
}
}
return $url;
} |
It seems this approach is used more often, so my bug report was bad but there is an actual issue :-/ public function createAbsoluteUrl($params, $scheme = null)
{
$params = (array) $params;
$url = $this->createUrl($params);
if (strpos($url, '://') === false) {
$hostInfo = $this->getHostInfo();
if (strncmp($url, '//', 2) === 0) {
$url = substr($hostInfo, 0, strpos($hostInfo, '://')) . ':' . $url;
} else {
$url = $hostInfo . $url;
}
}
return Url::ensureScheme($url, $scheme);
} Basically |
|
Yeah working on it |
…::createAbsoluteUrl(, ) method
What steps will reproduce the problem?
What is the expected result?
https://google.nl/test?param=https://someother.url/
What do you get instead?
google.nl/test?param=https://someother.url/
Additional info
This happens because this check is done:
We should use
parse_url
to get the correct parts instead of usingstrpos
.If
parse_url
is not available then we could at least split the string by?
to ensure we ignore the query part.The text was updated successfully, but these errors were encountered: