diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in index 4dbfd929a..7ed210920 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -9,6 +9,7 @@ local pairs = pairs local table = table local type = type local string = string +local pcall = pcall local capi = { screen = screen, awesome = awesome, dbus = dbus, @@ -354,9 +355,19 @@ function notify(args) local textbox = capi.widget({ type = "textbox", align = "flex" }) textbox:buttons(util.table.join(button({ }, 1, run), button({ }, 3, die))) layout.margins[textbox] = { right = margin, left = margin, bottom = margin, top = margin } - textbox.text = string.format('%s%s', font, title, text:gsub("", "\n")) textbox.valign = "middle" + local function setText(pattern, replacements) + textbox.text = string.format('%s%s', font, title, text:gsub(pattern, replacements)) + end + + -- First try to set the text while only interpreting
. + -- (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("[<>&]", { ['<'] = "<", ['>'] = ">", ['&'] = "&" }) + end + -- create iconbox local iconbox = nil if icon then