summaryrefslogtreecommitdiff
path: root/json.c
diff options
context:
space:
mode:
authorJoey Adams2010-08-05 04:17:51 +0000
committerJoey Adams2010-08-05 04:17:51 +0000
commit2a681508a61a8cdcc3fb67f0f014ddb0939c9b39 (patch)
treec962574f302e13bf668defcc6f8889031e3227c9 /json.c
parent1dab8166427da17d43c6ebaa6287447d3dd174b5 (diff)
Lifted 0xFFFE/0xFFFF Unicode code point restriction.
Requiring decoded escapes to not be 0xFFFE or 0xFFFF is overzealous, I think. In any case, this isn't even a comprehensive list of the codepoints considered "invalid". Also, removed utf8_encode_char helper function, as it was extremely trivial and used in only one place.
Diffstat (limited to 'json.c')
-rw-r--r--json.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/json.c b/json.c
index 440f6e0..3cbf46e 100644
--- a/json.c
+++ b/json.c
@@ -14,6 +14,8 @@
#include <ctype.h>
+#include "mb/pg_wchar.h"
+
#define is_internal(node) ((node)->type == JSON_ARRAY || (node)->type == JSON_OBJECT)
/* We can't use isspace() because it also accepts \v and \f, which
@@ -786,12 +788,11 @@ json_decode_string(const char **sp, size_t *length, bool strict)
uc = 0x10000 | ((uc & 0x3FF) << 10) | (lc & 0x3FF);
}
- /* 0xFFFE and 0xFFFF are invalid Unicode */
- if (uc == 0xFFFE || uc == 0xFFFF)
- goto failed;
+ unicode_to_utf8(uc, (unsigned char *) buf);
+ len = pg_utf_mblen((unsigned char *) buf);
- len = utf8_encode_char(buf, uc);
Assert(len > 0);
+
appendBinaryStringInfo(&ret, buf, len);
continue; /* Continue the enclosing while loop to skip