awful.menu: sanitize support for access keys

Commit 87070ca introduced support for access keys in menus. Chosen
character was "&", an XML entity that has potential to cause problems;
if a user tries to add multiple access keys or just put an ampersand
in the name of the item the menu will break. Breaking happened because
ampersands were not escaped - first one was substituted and the rest
were ignored, but not escaped which triggered a pango markup error.

Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Adrian C. (anrxc) 2010-02-21 00:58:07 +01:00 committed by Julien Danjou
parent b38569913c
commit 9f537bcb37
1 changed files with 5 additions and 4 deletions

View File

@ -208,10 +208,11 @@ local function add_item(data, num, item_info)
-- Create the item label widget -- Create the item label widget
local label = widget({ type = "textbox" }) local label = widget({ type = "textbox" })
local key = '' local key = ''
label.text = string.gsub(item_info[1], "&(%w)", function (l) label.text = string.gsub(util.escape(item_info[1]), "&amp;(%w)",
key= string.lower(l) function (l)
return "<u>"..l.."</u>" key = string.lower(l)
end, 1) return "<u>"..l.."</u>"
end, 1)
-- Set icon if needed -- Set icon if needed
local iconbox local iconbox
if item_info[3] then if item_info[3] then