[openbox/f16: 2/4] fix crash in xdg-menu (#799663)

Miroslav Lichvar mlichvar at fedoraproject.org
Fri Mar 30 13:46:14 UTC 2012


commit 27345f94e73765c1dd01576b6ecf66708a132b88
Author: Edward Sheldrake <ejsheldrake at gmail.com>
Date:   Fri Mar 30 14:56:41 2012 +0200

    fix crash in xdg-menu (#799663)

 xdg-menu |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
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 '<menu id="%s" label="%s"%s>' \
 			% (entry_name(entry),
 			entry_name(entry),
-			escape(icon_attr(entry)))
+			escape_utf8(icon_attr(entry)))
 		map(walk_menu, entry.getEntries())
 		print '</menu>'
 	elif isinstance(entry, xdg.Menu.MenuEntry) and entry.Show is True:
 		print '	<item label="%s"%s>' % \
 			(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():


More information about the scm-commits mailing list