Issue #2867749 by pfrenssen, claudiu.cristea: Parsing an URL with another URL in the query arguments throws undefined offset notice

8.4.x
Chris McCafferty 2017-04-27 15:45:08 -04:00
parent d2a5fe79e2
commit 3c72c97d0b
2 changed files with 7 additions and 1 deletions

View File

@ -142,7 +142,12 @@ class UrlHelper {
// External URLs: not using parse_url() here, so we do not have to rebuild // External URLs: not using parse_url() here, so we do not have to rebuild
// the scheme, host, and path without having any use for it. // the scheme, host, and path without having any use for it.
if (strpos($url, '://') !== FALSE) { // The URL is considered external if it contains the '://' delimiter. Since
// a URL can also be passed as a query argument, we check if this delimiter
// appears in front of the '?' query argument delimiter.
$scheme_delimiter_position = strpos($url, '://');
$query_delimiter_position = strpos($url, '?');
if ($scheme_delimiter_position !== FALSE && ($query_delimiter_position === FALSE || $scheme_delimiter_position < $query_delimiter_position)) {
// Split off everything before the query string into 'path'. // Split off everything before the query string into 'path'.
$parts = explode('?', $url); $parts = explode('?', $url);

View File

@ -736,6 +736,7 @@ class UrlTest extends UnitTestCase {
['/?page=1000'], ['/?page=1000'],
['?page=1000'], ['?page=1000'],
['?breed=bengal&page=1000'], ['?breed=bengal&page=1000'],
['?referrer=https://kittenfacts'],
// Paths with various token formats but no leading slash. // Paths with various token formats but no leading slash.
['/[duckies]'], ['/[duckies]'],
['/%bunnies'], ['/%bunnies'],