Remove manual XML entities escape in widgets

This commit is contained in:
Nguyễn Gia Phong 2018-10-22 00:20:01 +07:00
parent f1dd53edd2
commit 065bd1d009
6 changed files with 16 additions and 17 deletions

View File

@ -44,12 +44,10 @@ local function worker(format, warg)
for line in f:lines() do for line in f:lines() do
for module, value in string.gmatch(line, "([%w]+) (.*)$") do for module, value in string.gmatch(line, "([%w]+) (.*)$") do
if module == "file" then if module == "file" or module == "status" then
cmus_state["{"..module.."}"] = helpers.escape(value) cmus_state["{"..module.."}"] = value
elseif module == "duration" then elseif module == "duration" then
cmus_state["{"..module.."}"] = tonumber(value) cmus_state["{"..module.."}"] = tonumber(value)
elseif module == "status" then
cmus_state["{"..module.."}"] = value
else else
for k, v in string.gmatch(value, "([%w]+) (.*)$") do for k, v in string.gmatch(value, "([%w]+) (.*)$") do
if module == "tag" then if module == "tag" then

View File

@ -41,7 +41,7 @@ local function worker(format, warg)
end end
end end
return {helpers.escape(np)} return {np}
end end
-- }}} -- }}}

View File

@ -65,7 +65,7 @@ local function worker(format, warg)
end end
-- Spam sanitize the subject and store -- Spam sanitize the subject and store
mail["{subject}"] = helpers.escape(title) mail["{subject}"] = title
end end
f:close() f:close()

View File

@ -46,7 +46,7 @@ local function worker(format, warg)
end end
end end
return {helpers.escape(subject)} return {subject}
end end
-- }}} -- }}}

View File

@ -44,14 +44,15 @@ local function worker(format, warg)
for line in f:lines() do for line in f:lines() do
for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do
if k == "volume" then mpd_state["{"..k.."}"] = v and tonumber(v) local key = "{" .. k .. "}"
elseif k == "state" then mpd_state["{"..k.."}"] = helpers.capitalize(v) if k == "volume" then
elseif k == "Artist" then mpd_state["{"..k.."}"] = helpers.escape(v) mpd_state[key] = v and tonumber(v)
elseif k == "Title" then mpd_state["{"..k.."}"] = helpers.escape(v) elseif k == "state" then
elseif k == "Album" then mpd_state["{"..k.."}"] = helpers.escape(v) mpd_state[key] = helpers.capitalize(v)
elseif k == "Genre" then mpd_state["{"..k.."}"] = helpers.escape(v) elseif k == "Artist" or k == "Title" or
--elseif k == "Name" then mpd_state["{"..k.."}"] = helpers.escape(v) --k == "Name" or k == "file" or
--elseif k == "file" then mpd_state["{"..k.."}"] = helpers.escape(v) k == "Album" or k == "Genre" then
mpd_state[key] = v
end end
end end
end end

View File

@ -69,8 +69,8 @@ local function worker(format, warg)
-- Output differs from system to system, some stats can be -- Output differs from system to system, some stats can be
-- separated by =, and not all drivers report all stats -- separated by =, and not all drivers report all stats
winfo["{ssid}"] = -- SSID can have almost anything in it -- SSID can have almost anything in it
helpers.escape(string.match(iw, 'ESSID[=:]"(.-)"') or winfo["{ssid}"]) winfo["{ssid}"] = string.match(iw, 'ESSID[=:]"(.-)"') or winfo["{ssid}"]
winfo["{mode}"] = -- Modes are simple, but also match the "-" in Ad-Hoc winfo["{mode}"] = -- Modes are simple, but also match the "-" in Ad-Hoc
string.match(iw, "Mode[=:]([%w%-]*)") or winfo["{mode}"] string.match(iw, "Mode[=:]([%w%-]*)") or winfo["{mode}"]
winfo["{chan}"] = -- Channels are plain digits winfo["{chan}"] = -- Channels are plain digits