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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

roderik created an issue. See original summary.

roderik’s picture

Status: Active » Needs review
FileSize
1.32 KB

...and a fix.

The last submitted patch, link-validate-url-scheme-fail.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 2: link-3268969-2.patch, failed testing. View results

roderik’s picture

Status: Needs work » Needs review
FileSize
1.33 KB
656 bytes

Heh. Didn't pay attention when testing locally. Here's a new try.

renatog’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, great job @roderik. #5 really works well

  • RenatoG committed 9a718c6 on 7.x-1.x authored by roderik
    Issue #3268969 by roderik, RenatoG: Non-standard URL schemes with more...
renatog’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the dev branch. Thank you so much for your contribution @roderik

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.