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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-07-30 14:15:42 +02:00
parent 842dfc3064
commit fae5dfcd08
1 changed files with 3 additions and 1 deletions

View File

@ -365,7 +365,9 @@ function notify(args)
-- (Setting a textbox' .text to an invalid pattern throws a lua error)
if not pcall(setText, "<br.->", "\n") then
-- That failed, escape everything which might cause an error from pango
setText("[<>&]", { ['<'] = "&lt;", ['>'] = "&gt;", ['&'] = "&amp;" })
if not pcall(setText, "[<>&]", { ['<'] = "&lt;", ['>'] = "&gt;", ['&'] = "&amp;" }) then
textbox.text = "<i>&lt;Invalid markup, cannot display message&gt;</i>"
end
end
-- create iconbox