Copying and Pasting from Word inserts invalid characters

Bug #1698021 reported by Raoul Snyman
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenLP
Fix Committed
Medium
Phill

Bug Description

We have reports from users coming in all the time for this.

When a user copies and pastes a song from Word into OpenLP, Word seems to stick various control characters into the edit box which are invisible (or at least, plebians don't see them). When the user clicks "Save", the following exception is thrown:

Traceback (most recent call last):
File "openlp\plugins\songs\forms\editsongform.py", line 991, in accept
File "openlp\plugins\songs\forms\editsongform.py", line 1027, in save_song
File "openlp\plugins\songs\forms\editsongform.py", line 304, in _process_lyrics
File "openlp\plugins\songs\lib\openlyricsxml.py", line 102, in add_verse_to_lyrics
File "lxml.etree.pyx", line 2972, in lxml.etree.CDATA.__cinit__ (src\lxml\lxml.etree.c:69195)
File "apihelpers.pxi", line 1393, in lxml.etree._utf8 (src\lxml\lxml.etree.c:27125)
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

Can someone on Windows please try to reproduce this and figure out what those control characters are?

Related branches

Changed in openlp:
importance: Undecided → Medium
Revision history for this message
Tomas Groth (tomasgroth) wrote :

We could try to fix it by filtering out control chars as done here: https://stackoverflow.com/questions/8733233/filtering-out-certain-bytes-in-python
Note that there is a regex solution that is listed as the second answer that is much faster than the accepted answer...

Revision history for this message
Phill (phill-ridout) wrote :

Finally worked out how to reproduce this. Create a string with '\x0b'
 (vertical tab) and then paste that in to the song edit window and save!

Changed in openlp:
status: New → Confirmed
assignee: nobody → Phill (phill-ridout)
status: Confirmed → In Progress
Phill (phill-ridout)
Changed in openlp:
status: In Progress → Fix Committed
Tim Bentley (trb143)
Changed in openlp:
milestone: none → 2.5.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.