diff options
author | Jakub Zelenka <bukka@php.net> | 2016-02-29 19:31:20 +0000 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2016-02-29 19:31:20 +0000 |
commit | 70141093a731049ee9220e9e965f61ded56ed4d5 (patch) | |
tree | 6e67b382253a186889bfdc37c31062d6fb9880d9 /ext/json/json_encoder.c | |
parent | e453af3851daf08f5af9b45fc7819c3a9c336f1e (diff) | |
parent | 97294aca7e066443291cc2d77f8674ac23eabb32 (diff) | |
download | php-git-70141093a731049ee9220e9e965f61ded56ed4d5.tar.gz |
Merge branch 'master' into openssl_aead
Diffstat (limited to 'ext/json/json_encoder.c')
-rw-r--r-- | ext/json/json_encoder.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index 6c2f377034..8da5abd088 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -321,7 +321,7 @@ static void php_json_escape_string(smart_str *buf, char *s, size_t len, int opti do { us = (unsigned char)s[pos]; - if (us >= 0x80 && !(options & PHP_JSON_UNESCAPED_UNICODE)) { + if (us >= 0x80 && (!(options & PHP_JSON_UNESCAPED_UNICODE) || us == 0xE2)) { /* UTF-8 character */ us = php_next_utf8_char((const unsigned char *)s, len, &pos, &status); if (status != SUCCESS) { @@ -332,6 +332,15 @@ static void php_json_escape_string(smart_str *buf, char *s, size_t len, int opti smart_str_appendl(buf, "null", 4); return; } + /* Escape U+2028/U+2029 line terminators, UNLESS both + JSON_UNESCAPED_UNICODE and + JSON_UNESCAPED_LINE_TERMINATORS were provided */ + if ((options & PHP_JSON_UNESCAPED_UNICODE) + && ((options & PHP_JSON_UNESCAPED_LINE_TERMINATORS) + || us < 0x2028 || us > 0x2029)) { + smart_str_appendl(buf, &s[pos - 3], 3); + continue; + } /* From http://en.wikipedia.org/wiki/UTF16 */ if (us >= 0x10000) { unsigned int next_us; |