Description
moinmoin adds a trailing space to the last word of a paragraph in rendered html output. invisible to the eye but if the last word is selected and copy-pasted then a trailing space will be included.
this is particularly annoying if using moinmoin desktop edition as a password manager. most websites accept trailing spaces in the password field as part of the password. after copy-pasting the password from moinmoin the trailing space has to be removed manually (unless of course your password contains a trailing space).
Steps to reproduce
- create page with following content
the last word has a trailing space
- view page
doubleclick on last word (that would be space) to trigger highlighting of entire word (at least firefox under linux has this behaviour)
- copy to copy-paste-buffer (under linux the doubleclicking has already copied the text)
- paste in some text editor (under linux middle click)
- notice that the copy-pasted text includes a trailing space
if you have another browser or another system or somehow cannot doubleclick the word or it does not trigger highlighting of the word or whatever then you can also inspect the source code of the rendered html page.
it should look something like this:
<p class="line874">the last word has trailing space <span class="anchor" id="line-2">
notice the space between space and <span
Component selection
the bug is in the source file moindir/MoinMoin/parser/text_moin_wiki.py (moinmoin version 1.9.8)
line 1482:
# we don't have \n as whitespace any more # This is the space between lines we join to one paragraph line += ' '
this unconditionally adds a trailing space to every line. the idea is that if the following line will be merged to the current paragraph then the space is already there. but if the next line triggers a new paragraph then the last line has a trailing space.
http://hg.moinmo.in/moin/1.9/file/dbe605c5867c/MoinMoin/parser/text_moin_wiki.py#l1482
Details
MoinMoin Version |
1.9.8 |
OS and Version |
arch linux juli 2015 |
Python Version |
2.7.10 |
Server Setup |
desktop edition |
Server Details |
vanilla |
Language you are using the wiki in (set in the browser/UserPreferences) |
english |
Workaround
hack the code to remove the unconditional trailing space for every line and replace with a conditional leading space for the next line.
this can only be done in between line 1554 and 1555
original code:
# Scan line, format and write formatted_line = self.scan(line, inhibit_p=inhibit_p) self.request.write(formatted_line)
http://hg.moinmo.in/moin/1.9/file/dbe605c5867c/MoinMoin/parser/text_moin_wiki.py#l1554
fixed/workaround code:
# Scan line, format and write formatted_line = self.scan(line, inhibit_p=inhibit_p) # remove unconditional trailing space and replace with leading space if needed formatted_line = formatted_line.rstrip() if not self.line_was_empty: formatted_line = ' ' + formatted_line self.request.write(formatted_line)
this cannot be done sooner because the code between line 1482 and line 1554 depends on the trailing space. especially the self.scan() method breaks when the trailing space is removed.
this workaround has been tested on my moinmoin desktop edition. it is effective in preventing the trailing space and it seems to not break anything else.
Discussion
Plan
- Priority:
- Assigned to:
- Status: