Changeset 6419
- Timestamp:
- 11/13/10 14:16:51 (3 years ago)
- Files:
-
- 1 modified
-
luci/trunk/libs/core/luasrc/util.lua (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/core/luasrc/util.lua
r6410 r6419 32 32 local string = require "string" 33 33 local coroutine = require "coroutine" 34 local tparser = require "luci.template.parser" 34 35 35 36 local getmetatable, setmetatable = getmetatable, setmetatable … … 194 195 -- @param value String value containing the data to escape 195 196 -- @return String value containing the escaped data 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 ) or200 ( i >= 0x0E and i <= 0x1F ) or ( i == 0x7F )201 then202 return ""203 204 elseif ( i == 0x26 ) or ( i == 0x27 ) or ( i == 0x22 ) or205 ( i == 0x3C ) or ( i == 0x3E )206 then207 return string.format("&#%i;", i)208 end209 210 return c211 end212 213 197 function pcdata(value) 214 return value and t ostring(value):gsub("[&\"'<>%c]", _pcdata_repl)198 return value and tparser.sanitize_pcdata(tostring(value)) 215 199 end 216 200 … … 294 278 elseif type(v) == "table" then 295 279 v = table.concat(v, " ") 280 elseif type(v) ~= "string" then 281 v = tostring(v) 296 282 end 297 283
