projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c9556c0
)
libs/web: fix luci.http.write_json() to properly encode control chars in strings
author
Jo-Philipp Wich
<jow@openwrt.org>
Wed, 21 Nov 2012 16:04:13 +0000
(16:04 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Wed, 21 Nov 2012 16:04:13 +0000
(16:04 +0000)
libs/web/luasrc/http.lua
patch
|
blob
|
history
diff --git
a/libs/web/luasrc/http.lua
b/libs/web/luasrc/http.lua
index
1811250
..
c53307a
100644
(file)
--- a/
libs/web/luasrc/http.lua
+++ b/
libs/web/luasrc/http.lua
@@
-4,9
+4,6
@@
LuCI - HTTP-Interaction
Description:
HTTP-Header manipulator and form variable preprocessor
Description:
HTTP-Header manipulator and form variable preprocessor
-FileId:
-$Id$
-
License:
Copyright 2008 Steven Barth <steven@midlink.org>
License:
Copyright 2008 Steven Barth <steven@midlink.org>
@@
-334,12
+331,14
@@
function write_json(x)
end
elseif type(x) == "number" or type(x) == "boolean" then
if (x ~= x) then
end
elseif type(x) == "number" or type(x) == "boolean" then
if (x ~= x) then
- -- NaN is the only value that doesn't equal to itself.
+ -- NaN is the only value that doesn't equal to itself.
write("Number.NaN")
else
write(tostring(x))
end
else
write("Number.NaN")
else
write(tostring(x))
end
else
- write("%q" % tostring(x))
+ write('"%s"' % tostring(x):gsub('["%z\1-\31]', function(c)
+ return '\\u%04x' % c:byte(1)
+ end))
end
end
end
end