Description

The GUI editor breaks links that contain spaces.

Steps to reproduce

  1. Create a file with the following link using the text editor.
      [[file:///X:/data/my data/someinfo.txt|Local file]]
  2. Switch to the GUI editor and back to text editor. The link was replaced by the following:
      [[file:///X:/data/my%20data/someinfo.txt|Local file]]
  3. Compare the resulting html code
      <!-- html of the first link (correct code) -->
      <!-- The space is replaced by %20 by the browser (URI encoded) when clicked -->
      <a class="file" href="file:///X:/data/my data/someinfo.txt">Local file</a>
    
      <!-- html of the second link (incorrect uri for someinfo.txt) -->
      <!-- The string %20 is replaced by %2520 by the browser when clicked. The file is not found. -->
      <a class="file" href="file:///X:/data/my%20data/someinfo.txt">Local file</a>

Component selection

Details

MoinMoin Version

1.8.3

OS and Version

Python Version

Server Setup

Server Details

Language you are using the wiki in (set in the browser/UserPreferences)

Workaround

Discussion

I don't think this is a bug. A space is not a valid character in a URL and thus it is url-escaped to %20 (hex 20 is the code for a space char).

It is correct that a space has to be escaped by %20 in an url. But if the HTML-link (href attribute) contains the string "%20" instead of a space, the %-character will be escaped by %25 for the url encoded string resulting in "%2520" being requested by the browser. In HTML a space can be encoded by &nbsp; if this is required.

That sounds confusing. Let's just try: file:///c:/temp/foo%20bar.txt - I do not see a %25 there.

The generated html is:

<a class="file" href="file:///c:/temp/foo%20bar.txt">file:///c:/temp/foo%20bar.txt</a>

So, what's the problem (except that the original URL was not really valid, but was to an equivalent, but valid one)?

I've just been wondering because here it is working. The page that caused the problem used only two slashes ("file://c:/temp/foo bar.txt"). Maybe this is a bug in the IE6 that we need to use here. Try the following code using IE6 SP2.

 1. [[file:///C:/temp/foo bar.txt]]
 2. [[file:///C:/temp/foo%20bar.txt]]
 3. [[file://C:/temp/foo bar.txt]]
 4. [[file://C:/temp/foo%20bar.txt]]
  1. file:///C:/temp/foo%20bar.txt

  2. file:///C:/temp/foo%20bar.txt

  3. file://C:/temp/foo%20bar.txt

  4. file://C:/temp/foo%20bar.txt

The statusbar will show the following on mouseover with IE 6. Note that the IE appends the third slash.

  1. file:///C:/temp/foo bar.txt

  2. file:///C:/temp/foo%20bar.txt

  3. file:///C:/temp/foo%20bar.txt

  4. file:///C:/temp/foo%2520bar.txt

The Firefox 3.5 is working properly. But I think many user forget the third slash or even don't know that it is required. So maybe it is a good idea to append the third slash for local links when the page is stored? This should "fix" the IE-problem as well.

Just saw that the GUI editor is adding only two slashes for local links. I fixed our wiki in fckdialog.py like described below and at least new links that are added with the GUI editor are working with IE6.

   1 345c345
   2 <         <option value="file://">file://</option>
   3 ---
   4 >         <option value="file:///">file://</option>

Local links with only two slashes and a space that are added with the text editor will only work until the page is modified with the GUI editor.

Plan


CategoryMoinMoinNoBug

MoinMoin: MoinMoinBugs/1.8.3GUIEditorBreaksLinksWithSpaces (last edited 2009-09-09 16:05:52 by 212)