ezyang/htmlpurifier — pull request #42 by puckbag (2014-09-17 15:42:06+00:00)
Title: Use a more explicit URL regex to allow commas in a URL

I'm using an altered regex for parsing URLs in the Linkify injector. It's quite common for commas to come across unencoded in copy and paste actions from browsers. My experience writing regex look-arounds is limited so this regex could use some review but it works in all my use cases.

reference:
http://htmlpurifier.org/phorum/read.php?5,6970,6970

TESTS

normal:
http://www.google.com/

url with a comma:
https://www.google.com/maps/place/Googleplex/@37.422,-122.084058,17z/data=!3m1!4b1!4m2!3m1!1s0x808fba02425dad8f:0x6c296c66619367e0

url wrapped by bracket:
[http://www.google.com/]

url wrapped by parenthesis:
(http://www.google.com/)

url wrapped by quote:
'http://www.google.com/'

url wrapped by double quote:
"http://www.google.com/"

list separated by comma and space:
http://www.google.com/, http://facebook.com, http://twitter.com

list separated by bracket, comma and space:
[http://www.google.com/], [http://facebook.com], [http://twitter.com]

list separated by bracket and space:
[http://www.google.com/] [http://facebook.com] [http://twitter.com]

list separated by comma and no space (bad form, will result in single url):
http://www.google.com/,http://facebook.com,http://twitter.com

list separated by bracket and no space (bad form, will result in single url):
[http://www.google.com/][http://facebook.com][http://twitter.com]