In recent versions of guzzlehttp/psr7, the Uri class performs stricter validation of the input data. For example, this behavior can be observed starting from version 2.10.2:
https://github.com/guzzle/psr7/releases/tag/2.10.2
This may cause an issue in ConvertUrlElementFinderModifier.
The modifier currently uses parse_url() to validate URLs before passing them to GuzzleHttp\Psr7\Uri:
$isValid = parse_url($relative) !== false;
if ($isValid) {
$url = UriResolver::resolve($affected, new Uri($relative))->__toString();
}
However, parse_url() may accept values that are subsequently rejected by GuzzleHttp\Psr7\Uri.
For example:
"http://test test"
parse_url() does not reject this value, so $isValid is true. However, when the same value is passed to:
new Uri('http://test test')
an exception is thrown due to the stricter validation performed by Uri. As a result, the exception is not handled by ConvertUrlElementFinderModifier and the processing of the entire page fails.
There are also cases where an otherwise valid URL contains trailing whitespace, for example:
"http://validurl.com "
These cases could potentially be handled by trimming the value before validation and processing:
$relative = trim($relative);
In recent versions of
guzzlehttp/psr7,theUriclass performs stricter validation of the input data. For example, this behavior can be observed starting from version 2.10.2:https://github.com/guzzle/psr7/releases/tag/2.10.2
This may cause an issue in
ConvertUrlElementFinderModifier.The modifier currently uses
parse_url()to validate URLs before passing them toGuzzleHttp\Psr7\Uri:$isValid = parse_url($relative) !== false;However,
parse_url()may accept values that are subsequently rejected byGuzzleHttp\Psr7\Uri.For example:
"http://test test"
parse_url()does not reject this value, so$isValidis true. However, when the same value is passed to:new Uri('http://test test')an exception is thrown due to the stricter validation performed by Uri. As a result, the exception is not handled by
ConvertUrlElementFinderModifierand the processing of the entire page fails.There are also cases where an otherwise valid URL contains trailing whitespace, for example:
"http://validurl.com "
These cases could potentially be handled by trimming the value before validation and processing:
$relative = trim($relative);