More luci.util optimizations
This commit is contained in:
parent
9e2759ec34
commit
1a4c192c65
1 changed files with 8 additions and 9 deletions
|
@ -194,13 +194,13 @@ end
|
||||||
-- @param value String value containing the data to escape
|
-- @param value String value containing the data to escape
|
||||||
-- @return String value containing the escaped data
|
-- @return String value containing the escaped data
|
||||||
function pcdata(value)
|
function pcdata(value)
|
||||||
if not value then return end
|
return value and tostring(value):gsub("[&\"'<>]", {
|
||||||
value = tostring(value)
|
["&"] = "&",
|
||||||
value = value:gsub("&", "&")
|
['"'] = """,
|
||||||
value = value:gsub('"', """)
|
["'"] = "'",
|
||||||
value = value:gsub("'", "'")
|
["<"] = "<",
|
||||||
value = value:gsub("<", "<")
|
[">"] = ">"
|
||||||
return value:gsub(">", ">")
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Strip HTML tags from given string.
|
--- Strip HTML tags from given string.
|
||||||
|
@ -567,13 +567,12 @@ function _sortiter( t, f )
|
||||||
end
|
end
|
||||||
|
|
||||||
local _pos = 0
|
local _pos = 0
|
||||||
local _len = table.getn( keys )
|
|
||||||
|
|
||||||
table.sort( keys, f )
|
table.sort( keys, f )
|
||||||
|
|
||||||
return function()
|
return function()
|
||||||
_pos = _pos + 1
|
_pos = _pos + 1
|
||||||
if _pos <= _len then
|
if _pos <= #keys then
|
||||||
return keys[_pos], t[keys[_pos]]
|
return keys[_pos], t[keys[_pos]]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue