Skip to content
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

#20199 Reverted BaseUrl::isRelative() behaviour to previous 2.0.49 ve… #20203

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
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Yii Framework 2 Change Log

- Bug #20191: Fix `ActiveRecord::getDirtyAttributes()` for JSON columns with multi-dimensional array values (brandonkelly)
- Bug #20175: Fix bad result for pagination when used with GridView (@lav45)
- Bug #20199: Fix yii\web\UrlManager::createAbsoluteUrl() external absolute links creation (@edegaudenzi)


2.0.50 May 30, 2024
Expand Down
2 changes: 1 addition & 1 deletion framework/helpers/BaseUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
*/
public static function isRelative($url)
{
return preg_match('~^[[:alpha:]][[:alnum:]+-.]*://|^//~', $url) === 0;
return strncmp($url, '//', 2) && strpos($url, '://') === false;

Check warning on line 381 in framework/helpers/BaseUrl.php

View check run for this annotation

Codecov / codecov/patch

framework/helpers/BaseUrl.php#L381

Added line #L381 was not covered by tests
}

/**
Expand Down
14 changes: 11 additions & 3 deletions tests/framework/helpers/BaseUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ public function ensureSchemeUrlProvider()
'expected result' => 'acme.com?name=bugs.bunny',
],
'relative url and another url as parameter will return input url' => [
'url' => 'acme.com/test?tnt-link=https://tnt.com/',
'url' => 'acme.com/test?tnt-link=https%3A%2F%2Ftnt.com%2F%3Fq%3Dvalue',
'scheme' => 'https',
'expected' => 'acme.com/test?tnt-link=https://tnt.com/',
'expected' => 'acme.com/test?tnt-link=https%3A%2F%2Ftnt.com%2F%3Fq%3Dvalue',
],
'relative url and another url as parameter, using more relaxed rfc3986 3.4, will return input url' => [
'url' => 'acme.com/test?tnt-link=https%3A//tnt.com/?q%3Dvalue',
'scheme' => 'https',
'expected' => 'acme.com/test?tnt-link=https%3A//tnt.com/?q%3Dvalue',
],
'url with scheme not a string will return input url' => [
'url' => 'acme.com?name=bugs.bunny',
Expand Down Expand Up @@ -76,7 +81,10 @@ public function relativeTrueUrlProvider()
'url' => 'acme.com/tnt-room=123',
],
'url without protocol and another url in a parameter value' => [
'url' => 'acme.com?tnt-room-link=https://tnt.com',
'url' => 'acme.com?tnt-room-link=https%3A%2F%2Ftnt.com%2F%3Fq%3Dvalue',
],
'url without protocol and another url in a parameter value, using more relaxed rfc3986 3.4' => [
'url' => 'acme.com?tnt-room-link=https%3A//tnt.com/?q%3Dvalue',
],
'path only' => [
'url' => '/path',
Expand Down
Loading