diff options
author | Joey Adams | 2011-01-17 19:17:29 +0000 |
---|---|---|
committer | Joey Adams | 2011-01-17 19:17:29 +0000 |
commit | 59ad85e9165616e5de89b12465852ccf092f2e47 (patch) | |
tree | 999456033e9cd9cd227a860d32fc052e90f1814a | |
parent | 4869261b8a1ea6186b5d0c06d97c4296a2ce7bcf (diff) |
Fixed UTF-16 surrogate pair calculation to properly handle cases like "\uD840\uDC00".
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | expected/unicode.out | 7 | ||||
-rw-r--r-- | json.c | 2 | ||||
-rw-r--r-- | sql/unicode.sql | 2 |
4 files changed, 11 insertions, 2 deletions
@@ -3,7 +3,7 @@ OBJS = json.o jsonpath.o json_io.o json_op.o util.o DATA_built = json.sql DATA = uninstall_json.sql -REGRESS = init json validate condense orig json_path json_get json_set array_to_json +REGRESS = init json validate condense orig json_path json_get json_set array_to_json unicode ifdef USE_PGXS PG_CONFIG = pg_config diff --git a/expected/unicode.out b/expected/unicode.out new file mode 100644 index 0000000..a9f78b5 --- /dev/null +++ b/expected/unicode.out @@ -0,0 +1,7 @@ +-- Make sure the surrogate pair calculation adds 0x10000 rather than ORing it. +SELECT ascii(from_json($$ "\uD840\uDC00" $$)); + ascii +-------- + 131072 +(1 row) + @@ -824,7 +824,7 @@ json_decode_string(const char **sp, size_t *length, bool strict) s += 6; - uc = 0x10000 | ((uc & 0x3FF) << 10) | (lc & 0x3FF); + uc = 0x10000 + (((uc & 0x3FF) << 10) | (lc & 0x3FF)); } unicode_to_utf8(uc, (unsigned char *) buf); diff --git a/sql/unicode.sql b/sql/unicode.sql new file mode 100644 index 0000000..40e7b78 --- /dev/null +++ b/sql/unicode.sql @@ -0,0 +1,2 @@ +-- Make sure the surrogate pair calculation adds 0x10000 rather than ORing it. +SELECT ascii(from_json($$ "\uD840\uDC00" $$)); |