From 104876dd8e3ddb5cb46971a8e1be100ba7d9b432 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Mon, 28 Dec 2015 19:05:09 -0500 Subject: json_encode: Escape U+2028 and U+2029 more often. These characters are illegal in Javascript, so leaving them unescaped is risky. The default encoder ($flags = 0) is fine, but the encoder with JSON_UNESCAPED_UNICODE flag is not. In case anyone wants the ability to leave these characters unescaped, provide JSON_UNESCAPED_LINE_TERMINATORS. --- ext/json/json.c | 1 + 1 file changed, 1 insertion(+) (limited to 'ext/json/json.c') diff --git a/ext/json/json.c b/ext/json/json.c index 20bbcdc59e..971fe15f05 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -117,6 +117,7 @@ static PHP_MINIT_FUNCTION(json) PHP_JSON_REGISTER_CONSTANT("JSON_UNESCAPED_UNICODE", PHP_JSON_UNESCAPED_UNICODE); PHP_JSON_REGISTER_CONSTANT("JSON_PARTIAL_OUTPUT_ON_ERROR", PHP_JSON_PARTIAL_OUTPUT_ON_ERROR); PHP_JSON_REGISTER_CONSTANT("JSON_PRESERVE_ZERO_FRACTION", PHP_JSON_PRESERVE_ZERO_FRACTION); + PHP_JSON_REGISTER_CONSTANT("JSON_UNESCAPED_LINE_TERMINATORS", PHP_JSON_UNESCAPED_LINE_TERMINATORS); /* options for json_decode */ PHP_JSON_REGISTER_CONSTANT("JSON_OBJECT_AS_ARRAY", PHP_JSON_OBJECT_AS_ARRAY); -- cgit v1.2.1