1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00
This commit is contained in:
Nicolas Williams
2015-06-18 00:03:46 -05:00
parent 164b877bfa
commit 6083581fea
2 changed files with 6 additions and 2 deletions

5
jv.c
View File

@@ -717,7 +717,10 @@ jv jv_string_implode(jv j) {
for (i = 0; i < len; i++) {
jv n = jv_array_get(jv_copy(j), i);
assert(jv_get_kind(n) == JV_KIND_NUMBER);
s = jv_string_append_codepoint(s, jv_number_value(n));
int nv = jv_number_value(n);
if (nv > 0x10FFFF)
nv = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
s = jv_string_append_codepoint(s, nv);
}
jv_free(j);

View File

@@ -447,7 +447,8 @@ static pfunc found_string(struct jv_parser* p) {
codepoint = 0x10000 + (((codepoint - 0xD800) << 10)
|(surrogate - 0xDC00));
}
// FIXME assert valid codepoint
if (codepoint > 0x10FFFF)
codepoint = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
out += jvp_utf8_encode(codepoint, out);
break;