libs/web: fix luci.http.write_json() to properly encode control chars in strings

This commit is contained in:
Jo-Philipp Wich 2012-11-21 16:04:13 +00:00
parent c9556c02bb
commit 2675ad1c63

View file

@ -4,9 +4,6 @@ LuCI - HTTP-Interaction
Description:
HTTP-Header manipulator and form variable preprocessor
FileId:
$Id$
License:
Copyright 2008 Steven Barth <steven@midlink.org>
@ -340,6 +337,8 @@ function write_json(x)
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