Description

The html formatter in MoinMoin/formatter/text_html.py doesn't quote links properly.

Steps to reproduce

If you for have a link on your web page like so:

[[http://example.com/a+b=jee/test   test/|oho]]

You end up with html

<a class="http" href="http://example.com/a+b=jee/test   test/">oho</a>

which lacks proper quotation. The html should be:

<a class="http" href="http://example.com/a%2Bb%3Djee/test%20%20%20test/">oho</a>

Example

see above

Component selection

MoinMoin/formatter/text_html.py

Details

MoinMoin Version

1.9.8

OS and Version

any

Python Version

any

Server Setup

any

Server Details

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

Workaround

Discussion

You should add a quote function in html formatter since all macros and action that use it also won't have proper quoting. We initially ran into problems with an overeager proxy that dropped all traffic if it saw unquoted links.

I have a pull request at bitbucket which solves this issue: https://bitbucket.org/thomaswaldmann/moin-1.9/pull-request/6/quote-html-links-as-per-rfc3986/diff

I'm not the author of this fix but this is a patch we have been using to over come the problem.


Well, maybe let's first discuss whether this is a bug at all.

In the example you give, you have link markup that contains a invalid url (see URL spec, e.g. spaces are not allowed) and you expect from moin to make it valid for you.

Maybe it is just wrong expectations and you should just give valid URLs (like e.g. having %20 instead of a space?)

Just as a side note (this has nothing to do with moin, just as a note for practice): if you use firefox/linux and you select the url line content and use middle mouse button to insert it somewhere, you get that "pretty printed", but invalid URL. If you use copy and paste though, you'll get the real and valid URL.

So, in case we say "no bug", there is no fix needed. Just put valid URLs into your wiki text.

In case we end up saying moin behaviour should be changed, it needs to be considered that there is existing and working moin wiki text out there, so we would have to make sure that this still will work after the change.


I have to partly disagree here. I understand that if you put invalid urls on the wiki then there is a good reason to leave them there as they are. However initially we didn't have problems with spaces but with other characters like + and : which are reserved (along other chars) in RFC 2396. But the more important thing is that even if you have actions or macros that use the html formatter the links also will go unquoted. I tested this using a test macro and the output wasn't valid (according to the rfc). Of course you could argue that the author of the action/macro should do make sure that the links are properly quoted. But then again the RFC clearly states which characters should be quoted and I see no reason why MoinMoin shouldn't do it also.

--rauli

The argumentation somehow does not make sense to me yet (I am referring to the "no bug" case here). I say "give moin a valid url in the markup and you will have a valid url in the output". As it seems to just take it "as is", this seems to be always true, right?

Also, please rather update/refine/clarify the initial bug report than adding to the discussion part (e.g. if you don't mean spaces, don't put spaces there). Please also read section 2.2 of the rfc you point to and note that it says "limited to their reserved purpose". If you use the chars otherwise and do not quote them, your url (in wiki markup) is by definition invalid (and if input is invalid, the output will also be invalid, trash in, trash out).

-- ThomasWaldmann 2015-02-04 01:11:58

Plan


CategoryMoinMoinBug

MoinMoin: MoinMoinBugs/1.9HtmlFormatterDoesntQuoteLinksProperly (last edited 2015-02-04 01:11:59 by ThomasWaldmann)