-- @param value String value containing the data to escape
-- @return String value containing the escaped data
function pcdata(value)
- if not value then return end
- value = tostring(value)
- value = value:gsub("&", "&")
- value = value:gsub('"', """)
- value = value:gsub("'", "'")
- value = value:gsub("<", "<")
- return value:gsub(">", ">")
+ return value and tostring(value):gsub("[&\"'<>]", {
+ ["&"] = "&",
+ ['"'] = """,
+ ["'"] = "'",
+ ["<"] = "<",
+ [">"] = ">"
+ })
end
--- Strip HTML tags from given string.
end
local _pos = 0
- local _len = table.getn( keys )
table.sort( keys, f )
return function()
_pos = _pos + 1
- if _pos <= _len then
+ if _pos <= #keys then
return keys[_pos], t[keys[_pos]]
end
end