From fae5dfcd081a024ece5c7e8c270587d900cbdbc1 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 30 Jul 2010 14:15:42 +0200 Subject: [PATCH] Naughty: Handle invalid UTF-8 more sanely Previously, if setting the textbox's text failed this caused more problems later on. This commit makes sure that an invalid text never breaks pango. Signed-off-by: Uli Schlachter --- lib/naughty.lua.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in index 898efc0d..b1725cff 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -365,7 +365,9 @@ function notify(args) -- (Setting a textbox' .text to an invalid pattern throws a lua error) if not pcall(setText, "", "\n") then -- That failed, escape everything which might cause an error from pango - setText("[<>&]", { ['<'] = "<", ['>'] = ">", ['&'] = "&" }) + if not pcall(setText, "[<>&]", { ['<'] = "<", ['>'] = ">", ['&'] = "&" }) then + textbox.text = "<Invalid markup, cannot display message>" + end end -- create iconbox