When UrlHelper::parse() is parsing an internal URI which contains a URL in the query arguments then it throws the following notice:
Notice: Undefined offset: 1 in Drupal\Component\Utility\UrlHelper::parse() (line 151 of core/lib/Drupal/Component/Utility/UrlHelper.php).
This is caused by the method checking if the URI contains the string :// without verifying if this is part of the scheme, or in the query arguments. This causes the URI to be mistakenly considered an external URL and the wrong parse code path is entered.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | interdiff.txt | 939 bytes | pfrenssen |
| #11 | 2867749-11.patch | 1.58 KB | pfrenssen |
| #11 | 2867749-11-test_only.patch | 531 bytes | pfrenssen |
Comments
Comment #2
pfrenssenComment #4
claudiu.cristeaNice catch and nice that has also test coverage.
I wonder if we cannot write the change in a more cleaner way?
Comment #5
pfrenssenComment #6
pfrenssenI think my version is more readable actually. I had an earlier version that was more compact but it wasn't so clear why the check was being done so I made this more verbose version.
Comment #7
merilainen commentedSteps to reproduce?
Also I was reading on the backport policy document https://www.drupal.org/core/backport-policy which says that bug reports should be against the latest dev-branch which is now 8.4.x-dev, right? Not experienced with the 8.x minor update cycle, so bear with me...
Comment #8
pfrenssenTo reproduce:
Or, through the UI, create a link field that accepts internal links, and enter
?url=http://www.drupal.org.Since this is a bugfix this is still OK for 8.3.x, feature requests go to 8.4.x.
Comment #9
claudiu.cristeaProbably my proposed alternative is more a matter of perception, subjectivity and taste :)
The provided fix is correct and clear enough. Also we see the test proving the bug and we're covered. RTBC.
Comment #10
dawehnerIs it just me or could this need some additional documentation?
Comment #11
pfrenssenSure! Added some documentation.
Comment #12
claudiu.cristeaBack to RTBC.
Comment #14
alexpottComment #15
cilefen commentedComment #18
cilefen commentedCommitted 3c72c97 and pushed to 8.4.x, backported as bc7a744 and pushed to 8.3.x. Thanks!