Opened 16 years ago
Closed 16 years ago
#8300 closed defect (bug) (fixed)
Add parentheses to the list of valid URL characters for make_clickable function
Reported by: | josephscott | Owned by: | |
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | normal | Version: | 2.7 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
The make_clickable currently doesn't work correctly for URLs with parentheses like these:
http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software) http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx
By adding () to the list of valid URL characters these URLs are correctly detected. I've included a simple patch to do just that.
Attachments (4)
Change History (15)
#2
in reply to:
↑ 1
@
16 years ago
Replying to DD32:
You need to be careful about including parentheses in function to make links, As (http://blah.com/) should not be matched as a link, only the insides, yet http://blah.com/something(else)_another should..
There are some link parsing regular expressions around which deal with those cases specifically, somethin more robust might be required.
Just so happens that I just wrote some code to deal with this, so that this:
My site (http://josephscott.org)
So that the the open and closing parens are not included as part of the URL, will still supporting parens inside the URL.
I've updated the patch to reflect this.
#3
@
16 years ago
Actually, you can do this without having to modify _make_url_clickable_cb
: just change the regex to capture a closing parenthesis at the end of the URL only if the entire URL is not preceded by an opening parenthesis.
make_clickable_parenthesis.diff
gets all of the following examples right:
http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software) http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx My site (http://josephscott.org)
#4
@
16 years ago
Actually, it occurred to me that we could make _make_url_clickable_cb
even shorter, using the same regex technique to remove ending .,;:
, as seen in patch leaner_make_url_clickable_cb.diff
#5
@
16 years ago
I tried the changes in leaner_make_url_clickable_cb.diff and it failed to pick up the closing paren for this test case:
My (http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) article
That got converted to:
My (<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software))" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software))</a> article
That last ) should have been outside the </a> tag.
You need to be careful about including parentheses in function to make links, As (http://blah.com/) should not be matched as a link, only the insides, yet http://blah.com/something(else)_another should..
There are some link parsing regular expressions around which deal with those cases specifically, somethin more robust might be required.