GNOME Bugzilla – Bug 601171
Context pane crashes with lyrics containing invalid unicode
Last modified: 2018-05-24 14:51:18 UTC
The context pane plugin crashes Rhythmbox when attempting to display lyrics that contain invalid unicode characters. Traceback (most recent call last):
+ Trace 218932
stylesheet = self.styles)
return runtime._render(self, self.callable_, args, data)
_render_context(template, callable_, context, *args, **_kwargs_for_callable(callable_, data))
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
callable_(context, *args, **kwargs)
__M_writer(unicode(lyrics))
The code tries to turn the lyrics into a unicode object with unicode error checking enabled (which is the default behaviour for the function) but doesn't check for potential errors raised by the call. The actual call is made by code generated from the template by the template system. I'm not very familiar with Mako templates but I guess the code would either need to convert the string to proper unicode before using it in the template, or somehow tell the template system not to use strict error checking.
Looks like the cases I have at hand are all ones with 0x92 where there should be an apostrophe. All of these lyrics I've seen now that I started looking into it seem to be from lyrics.astraweb.com but not all lyrics from Astraweb suffer from it. The lyrics tab in the track properties window also fails to show these lyrics. Interestingly the characters appear correctly on the Astraweb site even though the character being transmitted is the same 0x92.
Looks like astraweb is claiming its responses are iso-8859-1 encoded but they're actually in windows-1250. 0x92 in that encoding is U+2019 (right single quotation mark), which gucharmap says is the preferred character to use for apostrophes. It probably gets displayed correctly on the site because web browsers are used to dealing with this sort of crap.
I've fixed the crash, which was not actually a crash, it was dbus exiting after being disconnected because we sent invalid utf8 strings. The lyrics plugin needs to do better charset conversion, and the context pane plugin probably needs to handle exceptions from the template code a bit better.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/rhythmbox/issues/838.