diff --git a/otouto/plugins/xkcd.lua b/otouto/plugins/xkcd.lua
index b75ba78..e5d27e5 100644
--- a/otouto/plugins/xkcd.lua
+++ b/otouto/plugins/xkcd.lua
@@ -39,13 +39,14 @@ function xkcd:action(msg, config)
utilities.send_reply(msg, config.errors.connection)
else
local data = JSON.decode(jstr)
- local output = string.format('*%s (*[%s](%s)*)*\n_%s_',
- utilities.fix_UTF8(data.safe_title):gsub('*', '*\\**'),
+ local output = string.format(
+ '%s (%s)\n%s',
+ utilities.html_escape(utilities.fix_utf8(data.safe_title)),
+ utilities.html_escape(data.img),
data.num,
- data.img,
- utilities.fix_UTF8(data.alt):gsub('_', '_\\__')
+ utilities.html_escape(utilities.fix_utf8(data.alt))
)
- utilities.send_message(msg.chat.id, output, false, nil, true)
+ utilities.send_message(msg.chat.id, output, false, nil, 'html')
end
end
diff --git a/otouto/utilities.lua b/otouto/utilities.lua
index 1e89a9c..8461ffc 100644
--- a/otouto/utilities.lua
+++ b/otouto/utilities.lua
@@ -321,14 +321,10 @@ utilities.style.enquote = function(title, body)
return '*' .. title:gsub('*', '\\*') .. ':*\n"' .. utilities.md_escape(body) .. '"'
end
--- Converts a string back into "proper" utf-8 from an ascii representation of utf-8
--- it is only useful for fixing improper encoding caused by bad JSON escaping
-function utilities.fix_UTF8(str)
- local t = {}
- for p, c in utf8.codes(str) do
- table.insert(t, string.char(c))
- end
- return table.concat(t)
+ -- Converts a gross string back into proper UTF-8.
+ -- Useful for fixing improper encoding caused by bad JSON escaping.
+function utilities.fix_utf8(str)
+ return string.char(utf8.codepoint(str, 1, -1))
end