The foswiki svn repository is obsolete. Developers should register for a http://github.com/ account for commit access to foswiki project. Github is ready for updates.

Item2367: In a forced wiki link, if a url occurs within the "text" part, illegal html is generated

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Closed Engine Renderer  
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 frown

-- CrawfordCurrie - 23 Jun 2010

ItemTemplate edit

Summary In a forced wiki link, if a url occurs within the "text" part, illegal html is generated
ReportedBy PatrickGosling
Codebase 1.0.7
SVN Range Foswiki-1.0.7, Sun, 20 Sep 2009, build 5061
AppliesTo Engine
Component Renderer
Priority Normal
CurrentState Closed
WaitingFor
Checkins Foswikirev:7895
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r8 - 04 Oct 2010, KennethLavrsen
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License