Opened 12 years ago
Last modified 5 years ago
#23922 new defect (bug)
make_clickable() breaks when colon in hash
Reported by: | Viper007Bond | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Formatting | Keywords: | needs-patch has-unit-tests |
Focuses: | Cc: |
Description
make_clickable()
doesn't like this string:
<a href="http://en.wikipedia.org/wiki/URI_scheme#tel:">http://en.wikipedia.org/wiki/URI_scheme#tel:</a>
It results in this HTML:
<a href="http://en.wikipedia.org/wiki/URI_scheme#tel:"><a href="http://en.wikipedia.org/wiki/URI_scheme#tel" rel="nofollow">http://en.wikipedia.org/wiki/URI_scheme#tel</a>:</a>
Specifically it's the colon that is causing the issue. It can be a part of the URL too, it doesn't have to be a part of an anchor.
Attachments (1)
Change History (8)
#2
@
12 years ago
- Summary changed from make_clickable() breaks when colon in path to make_clickable() breaks when colon in hash
Ah, okay. I fixed the ticket title then.
Really it should ignore anything inside of an existing <a>
tag (note it's making a hyperlink's text clickable) but I'm not sure how feasible that is while maintaining good regex performance.
#4
@
12 years ago
- Cc nashwan.doaqan@… added
in related to make_clickable() , could you see this ticket, please ? #23756
#5
@
11 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
Added a test method to check three potential URL structures:
- Url with trailing colon (used in ticket description)
- Url with embedded colon in hash (used in Trac URLs specifically)
- Url with trailing period
Finding parity between the first and third cases is the difficulty here. The original make_clickable()
method specifically only allows punctuation characters when followed by non-punctuation characters (meaning case #2 will actually work). Removing the colon from this punctuation check will allow case #1 to pass, but then case #2 will fail.
Whatever fix is introduced, retaining the functionality of case #3 (trailing non-colon punctuation) is vital to allowing links that are made clickable to be placed at the end of a sentence, before a coma, etc.
Well, colons are a reserved character and invalid in URLs: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm. But they're not uncommon in hashes. Trac uses them, for comments (#comment:0). I'd be inclined to allow colons when used in a hash. But not sure this is a defect.