Copying and Pasting from Word inserts invalid characters

Bug #1698021 reported by Raoul Snyman on 2017-06-14
This bug affects 2 people
Affects Status Importance Assigned to Milestone

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\", line 991, in accept
File "openlp\plugins\songs\forms\", line 1027, in save_song
File "openlp\plugins\songs\forms\", line 304, in _process_lyrics
File "openlp\plugins\songs\lib\", 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
Tomas Groth (tomasgroth) wrote :

We could try to fix it by filtering out control chars as done here:
Note that there is a regex solution that is listed as the second answer that is much faster than the accepted answer...

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) on 2017-11-11
Changed in openlp:
status: In Progress → Fix Committed
Tim Bentley (trb143) on 2017-11-11
Changed in openlp:
milestone: none → 2.5.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers