mate-desktop / mozo

Menu editor for MATE using the freedesktop.org menu specification
http://www.mate-desktop.org
GNU Lesser General Public License v2.1
28 stars 12 forks source link

Applications menu destroyed when processing a non-ASCII character. #29

Closed lah7 closed 8 years ago

lah7 commented 8 years ago

I had a menu entry named Life Is Strange™ (note the ™ character). When I used the tool to make adjustments to any application in the menu, there is an exception processing the ™ character which destroys this file: ~/.config/menus/mate-applications.menu. The application doesn't crash entirely.

This doesn't happen once the ™ character is manually deleted from the offending .desktop file.


Backtrace:

/usr/lib/python2.7/dist-packages/Mozo/MenuEditor.py:533: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if node.childNodes[0].nodeName == 'Filename' and node.childNodes[0].childNodes[0].nodeValue == filename:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/Mozo/MainWindow.py", line 430, in on_menu_tree_drag_data_received
    self.editor.copyItem(item, new_parent)
  File "/usr/lib/python2.7/dist-packages/Mozo/MenuEditor.py", line 298, in copyItem
    self.save()
  File "/usr/lib/python2.7/dist-packages/Mozo/MenuEditor.py", line 68, in save
    fd.write(re.sub("\n[\s]*([^\n<]*)\n[\s]*</", "\\1</", getattr(self, menu).dom.toprettyxml().replace('<?xml version="1.0" ?>\n', '')))
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 61, in toprettyxml
    return writer.getvalue()
  File "/usr/lib/python2.7/StringIO.py", line 271, in getvalue
    self.buf += ''.join(self.buflist)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 15: ordinal not in range(128)

Issues #26 and #28 are similar.


Originally raised here as a bug report here on Launchpad:

OS: Ubuntu MATE 16.04 Desktop: MATE 1.14

monsta commented 8 years ago

I presume this is the original app name in .desktop file, i.e. in English (US)? Because I have no issues when editing any menu item with localized description (in Russian in my case).

lah7 commented 8 years ago

Yep, although my system's locale is English (GB).

Actually, it turns out this bug is triggered when moving the launcher from one folder to another.

Here's a copy of the original .desktop file: Life Is Strange.desktop.gz

monsta commented 8 years ago

@XRevan86: can you please take a look at this? Seems like this started only with 1.14 - maybe some problem was introduced while migrating to GTK+3.

monsta commented 8 years ago

@lah7 @vendelin8 @HansPL Fix released in version 1.14.1, thanks to @XRevan86 :smile: