[geeklog-devel] COM_makeClickableLinks

Michael Jervis mjervis at gmail.com
Mon Jul 28 15:31:47 EDT 2008


All (especially Sami!),

There is a bug in the subject function. If it finds
"http://www.url.com" we end up with &nbsp<a
href=";http://www.url.com&nbsp">;http://www.url.com&nbsp</a>;

Which isn't good.

The original regexp in COM_MakeClickableLinks is:

/([^"]?)((((ht|f)tps?):(\/\/)|www\.)[a-z0-9%&_\-\+,;=:@~#\/.\?\[\]]+(\/|[+0-9a-z]))/is

I think the first match ([^"]?) is spurious, it matches anything other
than  " before a link. So bhttp://www.foo.com" matches, but
"http://www.foo.com doesn't.

So that gives:
/((((ht|f)tps?):(\/\/)|www\.)[a-z0-9%&_\-\+,;=:@~#\/.\?\[\]]+(\/|[+0-9a-z]))/is

Resulting in:
 <a href="http:///www.url.com&nbsp">http://www.url.com&nbsp</a>

So, need to add an "ignore trailing  " bit to the clause. Closest
I can get is:
((((ht|f)tps?):(\/\/)|www\.)[a-z0-9%&_\-\+,;=:@~#\/.\?\[\]]+(\/|[+0-9a-z]))(?= )

Which results in:
 <a href="http:///www.url.com">http://www.url.com</a> 

However, unless there were quotes round the link, it won't match! So
"http://www.foo.com" matches and is correctly processed, but
http://www.foo.com is not matched.

My head is now hurt. Any suggestions?

-- 
Michael Jervis
mjervis at gmail.com
504B03041400000008008F846431E3543A820800000006000000060000007765
62676F642B4F4D4ACF4F0100504B010214001400000008008F846431E3543A82
0800000006000000060000000000000000002000000000000000776562676F64
504B05060000000001000100340000002C0000000000



More information about the geeklog-devel mailing list