Welcome! » Log In » Create A New Profile

Linkify bug

Posted by nAS 
Linkify bug
May 20, 2013 10:32AM

Linkify directive doesn't work correctly when using no-breaking space or comma.

Example: http://bit.ly/11RAUaU

Proposed fix:

Linkify.php line 24 change from:

$bits = preg_split(&#039;#((?:https?|ftp)://[^\s\&#039;"<>()]+)#S&#039;, $token->data, -1, PREG_SPLIT_DELIM_CAPTURE);


$bits = preg_split(&#039;#((?:https?|ftp)://[^\s\&#039;",<>()]+)#Su&#039;, $token->data, -1, PREG_SPLIT_DELIM_CAPTURE);
Re: Linkify bug
May 21, 2013 04:29PM

Comma is a valid character in URLs, the non-breaking space change seems reasonable though. Perhaps a compromise we can make is only break on comma if it is immediately followed by a space.

Re: Linkify bug
May 21, 2013 04:59PM

Hmm, on further thought, I think I don't care. Committed.

Re: Linkify bug
May 21, 2013 06:25PM

That's exactly how I was thinking. I know that comma is valid in URL but all browsers encodes it as %2C. And I guess that it is more common use case that user wants to share multiple URLs separated by commas than sharing URL with unescaped comma.

It is possible to do better heuristic but I think that this approach is good enough.

Thank you for committing this, HTML Purifier is by far best HTML filtering tool!

Sorry, you do not have permission to post/reply in this forum.