well, when pasting a link starting with http:// prefix it outputs Not a valid URL. message, working with protocol prefix si required since i am planning to use it for ftp:// either.

CommentFileSizeAuthor
#1 protocol.patch.txt1.57 KBowen barton

Comments

owen barton’s picture

Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new1.57 KB

Making critical - since this bug prevents entry of any offsite URLs (not just ones with a protocol).

Here is a patch that fixes the problem. It also has improved the regex to function correctly for the mailto: protocol, since that does not include the '//' delimiter.

quicksketch’s picture

Looks good, is the line "+print $external_pattern . $end;" debugging code?

owen barton’s picture

Whoops!
Yes - that can be taken out :)

quicksketch’s picture

Status: Needs review » Fixed

Sorry about the delay on this patch! It really was quite a show-stopper!

Anyway, I found that your patch didn't actually help with mailto: since email addresses still don't fit the rest of the regular expression. I simply changed

  '/^(' . $allowed_protocols . ':\/\/)?'.

to

  '/^((' . $allowed_protocols . '):\/\/)?'.

Since the last protocol was being checked with the :// and the rest weren't. Released as version 1.2 on Drupal.org

Anonymous’s picture

Status: Fixed » Closed (fixed)