awful: check that text is not nil

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-08-04 16:21:12 +02:00
parent 9aa78f43e3
commit ac6093673d
1 changed files with 14 additions and 10 deletions

View File

@ -940,11 +940,13 @@ end
-- @param text Text to escape.
-- @return Escape text.
function escape(text)
text = text:gsub("&", "&amp;")
text = text:gsub("<", "&lt;")
text = text:gsub(">", "&gt;")
text = text:gsub("'", "&apos;")
text = text:gsub("\"", "&quot;")
if text then
text = text:gsub("&", "&amp;")
text = text:gsub("<", "&lt;")
text = text:gsub(">", "&gt;")
text = text:gsub("'", "&apos;")
text = text:gsub("\"", "&quot;")
end
return text
end
@ -952,11 +954,13 @@ end
-- @param text Text to unescape.
-- @return Unescaped text.
function unescape(text)
text = text:gsub("&amp;", "&")
text = text:gsub("&lt;", "<")
text = text:gsub("&gt;", ">")
text = text:gsub("&apos;", "'")
text = text:gsub("&quot;", "\"")
if text then
text = text:gsub("&amp;", "&")
text = text:gsub("&lt;", "<")
text = text:gsub("&gt;", ">")
text = text:gsub("&apos;", "'")
text = text:gsub("&quot;", "\"")
end
return text
end