diff --git a/xdg-menu b/xdg-menu index 4f16438..aefc6a4 100644 --- a/xdg-menu +++ b/xdg-menu @@ -52,21 +52,24 @@ def icon_attr(entry): return ' icon="' + iconfile + '"' return '' +def escape_utf8(s): + return escape(s.encode('utf-8', 'xmlcharrefreplace')) + def entry_name(entry): - return escape(entry.getName().encode('utf-8', 'xmlcharrefreplace')) + return escape_utf8(entry.getName()) def walk_menu(entry): if isinstance(entry, xdg.Menu.Menu) and entry.Show is True: print '' \ % (entry_name(entry), entry_name(entry), - escape(icon_attr(entry))) + escape_utf8(icon_attr(entry))) map(walk_menu, entry.getEntries()) print '' elif isinstance(entry, xdg.Menu.MenuEntry) and entry.Show is True: print ' ' % \ (entry_name(entry.DesktopEntry).replace('"', ''), - escape(icon_attr(entry.DesktopEntry))) + escape_utf8(icon_attr(entry.DesktopEntry))) command = re.sub(' -caption "%c"| -caption %c', ' -caption "%s"' % entry_name(entry.DesktopEntry), entry.DesktopEntry.getExec()) command = re.sub(' [^ ]*%[fFuUdDnNickvm]', '', command) if entry.DesktopEntry.getTerminal():