Item2367: In a forced wiki link, if a url occurs within the "text" part, illegal html is generated
Priority: Normal
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
Component: Renderer
Branches:
If I force a wiki link using the
[[][]]
syntax, and there is a url in the second part, the generated html is illegal (and quite odd).
For instance, if I say
[[http://www.cam.ac.uk/][Link to http://www.cam.ac.uk/]]
then the generated html will be (modulo some newlines for clarity ...)
<a href="http://www.cam.ac.uk/" target="_top">
Link to <a href="http://www.cam.ac.uk</a>" target="_top">
http://www.cam.ac.uk/]]</a>
Although I've given a rather un-wiki-ish example here, I don't think that it's in general inappropriate to include urls in the text part of a forced link.
Now this failure can be avoided by explicitly suppressing linking on the url as follows:
[[http://www.cam.ac.uk/][Link to !http://www.cam.ac.uk/]]
but I would argue that the need to do so is counter-intuitive, and that it is in any event wrong to produce illegal html sequences in such a situation.
Link to http://www.cam.ac.uk/
It appears that the problem is that http: links are rendered before bracketed links are processed. So by the time the bracketed link is being rendered, the
http:// link has already been rendered. Adding an escape to the bracketed link handling is too late. I've created a unit test and can fix the issue by deferring
http:// link processing until after the bracketed links are processed, and adding code to escape link strings from the link text similar to the
WikiWord escapes. But I'm concerned that changing the rendering order could have other significant side effects.
--
GeorgeClark - 23 Jun 2010
I agree. I moved the order round so that the external link was rendered after the squabbed link, which works for this example but may have undesirable effects elsewhere - not sure how we can tell.
--
CrawfordCurrie - 23 Jun 2010
Unit tests all seem fine, and I played around with it quite a bit - I can't see any reason not to go ahead with this change. Apologies that it's tangled up with another checkin that I had pending simultaneously
--
CrawfordCurrie - 23 Jun 2010