summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-09-10 12:47:21 +0000
committerSteven Barth <steven@midlink.org>2008-09-10 12:47:21 +0000
commit1a4c192c65c166304014075857d7568cb4e7ae5b (patch)
treef2ffbc393f89ac3d353e8b7829e44c7cec8bc15a
parent9e2759ec348c4b44475fd594d91eab14e7e3220e (diff)
More luci.util optimizations
-rw-r--r--libs/core/luasrc/util.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua
index c84df1a170..95491cfee0 100644
--- a/libs/core/luasrc/util.lua
+++ b/libs/core/luasrc/util.lua
@@ -194,13 +194,13 @@ end
-- @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("&", "&amp;")
- value = value:gsub('"', "&quot;")
- value = value:gsub("'", "&apos;")
- value = value:gsub("<", "&lt;")
- return value:gsub(">", "&gt;")
+ return value and tostring(value):gsub("[&\"'<>]", {
+ ["&"] = "&amp;",
+ ['"'] = "&quot;",
+ ["'"] = "&apos;",
+ ["<"] = "&lt;",
+ [">"] = "&gt;"
+ })
end
--- Strip HTML tags from given string.
@@ -567,13 +567,12 @@ function _sortiter( t, f )
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