Roxen.git/
server/
etc/
modules/
Roxen.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2011-09-13
2011-09-13 14:46:28 by Henrik Grubbström (Grubba) <grubba@grubba.org>
51ed75bcc8484b5a235083b8f1d171708ba544d5 (
17
lines) (+
16
/-
1
)
[
Show
|
Annotate
]
Branch:
5.2
Added "json" encoding. Fixes [bug
6056 (#6056)
].
Rev: server/etc/modules/Roxen.pmod:1.316
1:
// This is a roxen pike module. Copyright © 1999 - 2009, Roxen IS. //
-
// $Id: Roxen.pmod,v 1.
315
2011/09/
12
10
:
54
:
42
grubba Exp $
+
// $Id: Roxen.pmod,v 1.
316
2011/09/
13
14
:
46
:
28
grubba Exp $
#include <roxen.h> #include <config.h>
2860:
({ "\"", "\\", "\n" }), ({ "\\\"", "\\\\", "\\n" }));
+
case "json":
+
// RFC 4627, section 2.5
+
//
+
// Perform the set of single-character escapes specified there.
+
//
+
// Note that further escapes may optionally be performed using
+
// the syntax \uXXXX, where characters outside the BMP first
+
// are split into UTF-16 surrogate pairs.
+
return replace(val,
+
({ "\"", "\\", "/", "\b",
+
"\f", "\n", "\r", "\t" }),
+
({ "\\\"", "\\\\", "\\/", "\\b",
+
"\\f", "\\n", "\\r", "\\t" }));
+
case "js": case "javascript": return replace (val,