Songs with mismatching formatting tags still throw an exception

Bug #1173749 reported by Raoul Snyman
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenLP
Status tracked in Trunk
2.0
Fix Released
High
Oliver Wieland
Trunk
Fix Released
High
Samuel Mehrbrodt

Bug Description

There is another bug similar to this, bug #885874, but it does not seem to have fixed the issue below. Note that there is a mismatched "{/g}" tag which causes this error.

Version: {u'full': u'2.0.1', u'version': u'2.0.1', u'build': None}

--- Details of the Exception. ---

Hi,
I just found one bug. I just changed one Bridge to:

Shine Your light and {g}Strahle hell und{/g}
Let the whole world see {g}lass die Welt es sehn.{/g}
We're singing {g}Wir singen{/g}
For the glory Of the risen King{/g} {g}dir zur Ehre, auferstandner Herr.{/g}
Jesus

And got this error:

--- Exception Traceback ---
Traceback (most recent call last):
File
"/usr/lib/pymodules/python2.6/openlp/plugins/songs/lib/mediaitem.py",
line 393, in onEditClick
self.onSongListLoad()
File
"/usr/lib/pymodules/python2.6/openlp/plugins/songs/lib/mediaitem.py",
line 254, in onSongListLoad
item = self.buildServiceItem(self.editItem)
File
"/usr/lib/pymodules/python2.6/openlp/core/lib/mediamanageritem.py", line
591, in buildServiceItem
if self.generateSlideData(serviceItem, item, xmlVersion, remote):
File
"/usr/lib/pymodules/python2.6/openlp/plugins/songs/lib/mediaitem.py",
line 529, in generateSlideData
service_item.xml_version = self.openLyrics.song_to_xml(song)
File "/usr/lib/pymodules/python2.6/openlp/plugins/songs/lib/xml.py",
line 361, in song_to_xml
optional_verse, tags_element)
File "/usr/lib/pymodules/python2.6/openlp/plugins/songs/lib/xml.py",
line 503, in _add_text_with_tags_to_lines
element = etree.XML
File "lxml.etree.pyx", line 2512, in lxml.etree.XML
(src/lxml/lxml.etree.c:48057)
File "parser.pxi", line 1545, in lxml.etree._parseMemoryDocument
(src/lxml/lxml.etree.c:71812)
File "parser.pxi", line 1417, in lxml.etree._parseDoc
(src/lxml/lxml.etree.c:70608)
File "parser.pxi", line 898, in
lxml.etree._BaseParser._parseUnicodeDoc (src/lxml/lxml.etree.c:67148)
File "parser.pxi", line 539, in
lxml.etree._ParserContext._handleParseResultDoc
(src/lxml/lxml.etree.c:63824)
File "parser.pxi", line 625, in lxml.etree._handleParseResult
(src/lxml/lxml.etree.c:64745)
File "parser.pxi", line 565, in lxml.etree._raiseParseError
(src/lxml/lxml.etree.c:64088)
XMLSyntaxError: Opening and ending tag mismatch: lines line 1 and tag,
line 1, column 216

--- System information ---
Plattform: Linux-2.6.32-45-generic-i686-with-Ubuntu-10.04-lucid
Desktop: GNOME

--- Library Versions ---
Python: 2.6.5
Qt4: 4.6.2
Phonon: 4.3.1
PyQt4: 4.7.2
QtWebkit: 532.4
SQLAlchemy: 0.5.8
SQLAlchemy Migrate: < 0.7
BeautifulSoup: 3.1.0.1
lxml: 2.2.4
Chardet: 2.0.1
PyEnchant: 1.5.3
PySQLite: 1.0.1
Mako: 0.2.5
pyUNO bridge: 3.2

Related branches

Revision history for this message
Oliver Wieland (oliwee) wrote :

I think the problem is, that the method '_get_missing_tags' only checks for 'not closed' tags, but not for 'not opened'.
I'm nearly a Phyton newbie, therefore I don't understand the complete code around this method and the following calls in 'song_to_xml', so I'm sorry that i cannot fix the problem for myself.

Revision history for this message
Oliver Wieland (oliwee) wrote :

I wrote a function which checks the consistency of the tags in the verse.

The question is: What is the appropriate reaction of the program if the function returns there is a malplaced tag?
Should the whole import be canceled?

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

I think there is really two parts to this bug.

1. We should validate the formatting tags when a user enters a song manually:
    a) For 2.0 series think we should display a message box saying that the formatting tags are invalid.
    b) For trunk series, I was thinking it would be nice if we could highlight the actual issues. Either with a message box for example "x opening tag found, but no closing tag" or by actually changing the background colour of the tag to red or something.

2. For songs that are being imported or songs that are already in the database we should either remove the tag, or close it just before the next closing tag or split.

Revision history for this message
Oliver Wieland (oliwee) wrote :

1a) So the users can't leave the editor before fixing the malformed tags? This would be the easiest solution, but not very user friendly. The user should have the possibility to save a song every time, even when it is malformed. Anyway, a message box should point out the user that there is an error an that the song could not be used in this state.

1b) This would be the advanced version of 1a, showing the wrong tags by coloring them. Nice.

2. I don't think so. In my opinion there mustn't be any changes on any song without the knowledge of the user.
You don't know, if there is a tag too much or too less or if this is a wrong written tag or ...
The user has to decide what to do with this malformed song.
Possible actions would be: Cancel import or show song in editor. Maybe ignoring the issue would be a possibility, too.

Revision history for this message
Phill (phill-ridout) wrote : Re: [Bug 1173749] Re: Songs with mismatching formatting tags still throw an exception

> 1a) So the users can't leave the editor before fixing the malformed
> tags? This would be the easiest solution, but not very user friendly.
> The user should have the possibility to save a song every time, even
> when it is malformed. Anyway, a message box should point out the user
> that there is an error an that the song could not be used in this state.

That would just be a stop gap soloutuon for 2.0. I think this is the most
as we can do seeming as we are not adding any new features to this release.
Its more user friendly than the current solution of showing the user a
criptic error message!

> 1b) This would be the advanced version of 1a, showing the wrong tags by
coloring them. Nice.

This would be for trunk (a.k.a 2.1) which we are adding features to.
Andreas' input on this would be valuable as he was having a look at
creating a WYSIWYG editor for the songs.

> 2. I don't think so. In my opinion there mustn't be any changes on any
song without the knowledge of the user.
> You don't know, if there is a tag too much or too less or if this is a
wrong written tag or ...

In which case we should just ignore it. The last thing I would want is to
have to find and show a song during spontaneous worship, and then for
OpenLP to force me to edit it before showing it.

> The user has to decide what to do with this malformed song.
> Possible actions would be: Cancel import or show song in editor. Maybe
ignoring the issue would be a possibility, too.

Unfortunately with a lot of the song importers we just have to make
assumptions about what we're importing. I don't think there is a single
importer which keeps formatting data (with the exception of possibly
OpenLyrics). We could log which files we had to drop any formatting from in
the import wizard.

Revision history for this message
Oliver Wieland (oliwee) wrote :

1a) I see. So the best solution for 2.0 series would be a message box when the user leaves the song editor, without let him out before he has fixed the problem. I think with my quick'n'dirty function this should be no too hard. I'll try that at the weekend.

2) I do not know anything about the importers, so I guess you are right ;) A logging about the issues while the import should be a must have. The question is: Should this be implemented in 2.0? As you said, it's not very nice if you import a song quickly for a spontaneus worship and when the song should be displayed, OpenLP fires an exception...

Revision history for this message
Oliver Wieland (oliwee) wrote :

1a) is done for 2.0 series. See linked branch.
I'm not sure if I should propose for merging, because it's assigned to V2.0.3. Maybe I should wait until 2.0.2 is released?

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

Additionally we should probably try and catch this error and issue a friendly warning to the user.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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