* Replaced luafilesystem with luaposix library
[project/luci.git] / src / ffluci / util.lua
index 85092f0..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)))