* Replaced luafilesystem with luaposix library
[project/luci.git] / src / ffluci / util.lua
index f2180e7..c47a898 100644 (file)
@@ -150,6 +150,16 @@ function instanceof(object, class)
 end
 
 
+-- Creates valid XML PCDATA from a string
+function pcdata(value)
+       value = value:gsub("&", "&")        
+       value = value:gsub('"', """)
+       value = value:gsub("'", "'")
+       value = value:gsub("<", "&lt;") 
+       return value:gsub(">", "&gt;")
+end
+
+
 -- Resets the scope of f doing a shallow copy of its scope into a new table
 function resfenv(f)
        setfenv(f, clone(getfenv(f)))
@@ -203,7 +213,7 @@ end
 
 
 -- Validates a variable
-function validate(value, valid, cast_number, cast_int)
+function validate(value, cast_number, cast_int)
        if cast_number or cast_int then
                value = tonumber(value)
        end
@@ -212,15 +222,6 @@ function validate(value, valid, cast_number, cast_int)
                value = nil
        end
        
-       
-       if type(valid) == "function" then
-               value = valid(value)
-       elseif type(valid) == "table" then
-               if not contains(valid, value) then
-                       value = nil
-               end
-       end
-       
        return value
 end