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