diff options
author | Jakub Zelenka <bukka@php.net> | 2016-06-19 16:20:02 +0100 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2016-06-19 16:20:02 +0100 |
commit | c2b90805e81de43b4fa28fa1b30ed255bfba76b2 (patch) | |
tree | a353bb7b1cb958fd4f3e576ab44f3b6ef03a02c2 /ext/json/json_encoder.c | |
parent | b44cf1a8540d321583a0d83ebca688ebab10d3b0 (diff) | |
parent | d0e84c6f4702dc5dda473851dd33c5e6cee82ee6 (diff) | |
download | php-git-c2b90805e81de43b4fa28fa1b30ed255bfba76b2.tar.gz |
Merge branch 'master' into openssl_error_store
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 ae9e086fc0..62df102847 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; |