I would really appreciate it if you could take a look at the following regexes and let me know if there are any problems, including security issues. Handling URLs has proved to be tricky and I'm concerned I'm too forgiving in what I accept.
They are from a bulletin board script where the user can input a link in their post witrh the following formats:
[link]http://www.website.com[/url] or
[link=http://www.website.com]A Cool Site[/url]
The code of that handles the above exapmples is (note $post has been HTML esacped):
$post =~ s/\[link\]((?:ht|f)tp(?:s?):\/\/(?:\w+)\.(?:\S+?))\[\/link\]/<A HREF="$1" TARGET="_blank">$1<\/A>/gis;
$post =~ s/\[link\=((?:ht|f)tp(?:s?):\/\/(?:\w+)\.(?:\S+?))\](.+?)\[\/link\]/<A HREF="$1" TARGET="_blank">$2<\/A>/gis;
They are from a bulletin board script where the user can input a link in their post witrh the following formats:
[link]http://www.website.com[/url] or
[link=http://www.website.com]A Cool Site[/url]
The code of that handles the above exapmples is (note $post has been HTML esacped):
$post =~ s/\[link\]((?:ht|f)tp(?:s?):\/\/(?:\w+)\.(?:\S+?))\[\/link\]/<A HREF="$1" TARGET="_blank">$1<\/A>/gis;
$post =~ s/\[link\=((?:ht|f)tp(?:s?):\/\/(?:\w+)\.(?:\S+?))\](.+?)\[\/link\]/<A HREF="$1" TARGET="_blank">$2<\/A>/gis;