Rewrite of the escape helper.
It is simillar to the awful.util.escape now, using a table which we could expand (and rename) with other unwated characters if it comes to that. I saw awesome break on many occasions because of encoding problems.
This commit is contained in:
parent
047dba0e5d
commit
09fda0ab05
16
helpers.lua
16
helpers.lua
|
@ -101,15 +101,15 @@ end
|
|||
|
||||
--{{{ Escape a string
|
||||
function escape(text)
|
||||
if text then
|
||||
text = text:gsub("&", "&")
|
||||
text = text:gsub("<", "<")
|
||||
text = text:gsub(">", ">")
|
||||
text = text:gsub("'", "'")
|
||||
text = text:gsub("\"", """)
|
||||
end
|
||||
local xml_entities = {
|
||||
["\""] = """,
|
||||
["&"] = "&",
|
||||
["'"] = "'",
|
||||
["<"] = "<",
|
||||
[">"] = ">"
|
||||
}
|
||||
|
||||
return text
|
||||
return text and text:gsub("[\"&'<>]", xml_entities)
|
||||
end
|
||||
-- }}}
|
||||
-- }}}
|
||||
|
|
Loading…
Reference in New Issue