Changeset 4119
- Timestamp:
- 01/25/09 14:14:29 (4 years ago)
- Files:
-
- 1 modified
-
luci/branches/luci-0.8/libs/core/luasrc/util.lua (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
luci/branches/luci-0.8/libs/core/luasrc/util.lua
r3941 r4119 194 194 -- @param value String value containing the data to escape 195 195 -- @return String value containing the escaped data 196 local _pcdata_repl = { 197 ["&"] = "&", 198 ['"'] = """, 199 ["'"] = "'", 200 ["<"] = "<", 201 [">"] = ">" 202 } 196 local function _pcdata_repl(c) 197 local i = string.byte(c) 198 199 if ( i >= 0x00 and i <= 0x08 ) or ( i >= 0x0B and i <= 0x0C ) or 200 ( i >= 0x0E and i <= 0x1F ) or ( i == 0x7F ) 201 then 202 return "" 203 204 elseif ( i == 0x26 ) or ( i == 0x27 ) or ( i == 0x22 ) or 205 ( i == 0x3C ) or ( i == 0x3E ) 206 then 207 return string.format("&#%i;", i) 208 end 209 210 return c 211 end 203 212 204 213 function pcdata(value) 205 return value and tostring(value):gsub("[&\"'<> ]", _pcdata_repl)214 return value and tostring(value):gsub("[&\"'<>%c]", _pcdata_repl) 206 215 end 207 216
