This is another but introduced by #2247261: URLs are not validated the 7.x-1.4 release.
I.e. this is another sibling of #2666912: URL validation rejects existing valid content after upgrade to 7.x-1.4. But that issue does not have a clear problem description, so I'm making a new issue.
Problem/Motivation
drupal_valid_path()
has no good support for non-standard URL schemes; e.g.
irc://host
passes
irc://host/path
fails.
This is because the following code block is executed rather arbitrarily:
$flag = valid_url($text, $type == LINK_EXTERNAL);
if (!$flag) {
$normal_path = drupal_get_normal_path($text, $langcode);
$parsed_link = parse_url($normal_path, PHP_URL_PATH);
if ($normal_path != $parsed_link) {
$normal_path = $parsed_link;
}
$flag = drupal_valid_path($normal_path);
}
In the first case, parse_url($normal_path, PHP_URL_PATH);
is NULL, and drupal_valid_path(NULL)
is TRUE... in most cases.
In the second case, parse_url($normal_path, PHP_URL_PATH);
is a string, and drupal_valid_path(NULL)
is FALSE... in most cases.
But really this whole logic should not be executed for these non-standard scheme.
Steps to reproduce
See test fail.
Proposed resolution
See patch.
Comment | File | Size | Author |
---|---|---|---|
#5 | interdiff-3268969-2-5.txt | 656 bytes | roderik |
#5 | link-3268969-5.patch | 1.33 KB | roderik |
| |||
link-validate-url-scheme-fail.patch | 541 bytes | roderik | |
Comments
Comment #2
roderik...and a fix.
Comment #5
roderikHeh. Didn't pay attention when testing locally. Here's a new try.
Comment #6
renatogYeah, great job @roderik. #5 really works well
Comment #8
renatogCommitted to the dev branch. Thank you so much for your contribution @roderik