Tasklist: Fail less badly with invalid utf8
xterm is famous for messing up the utf8 in its title (unless correctly configured). Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
a4b8fc4894
commit
9e79d18747
|
@ -7,6 +7,7 @@
|
|||
-- Grab environment we need
|
||||
local math = math
|
||||
local type = type
|
||||
local pcall = pcall
|
||||
local ipairs = ipairs
|
||||
local setmetatable = setmetatable
|
||||
local capi = { widget = widget, button = button }
|
||||
|
@ -73,7 +74,13 @@ function list_update(w, buttons, label, data, widgets, objects)
|
|||
end
|
||||
|
||||
local text, bg, bg_image, icon = label(o)
|
||||
w[k + 1].text, w[k + 1].bg, w[k + 1].bg_image = text, bg, bg_image
|
||||
|
||||
-- Check if we got a valid text here, it might contain e.g. broken utf8.
|
||||
if not pcall(function() w[k + 1].text = text end) then
|
||||
w[k + 1].text = "<i>Invalid</i>"
|
||||
end
|
||||
|
||||
w[k + 1].bg, w[k + 1].bg_image = bg, bg_image
|
||||
w[k].bg, w[k].image = bg, icon
|
||||
if not w[k + 1].text then
|
||||
w[k+1].visible = false
|
||||
|
|
Loading…
Reference in New Issue