mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 05:44:58 +00:00
AK: JSON, Escape spacial character in string serialization
This commit is contained in:
parent
0b74ea3d6a
commit
8e9776165f
2 changed files with 47 additions and 11 deletions
|
@ -116,14 +116,22 @@ String JsonParser::consume_quoted_string()
|
|||
case 'f':
|
||||
buffer.append('\f');
|
||||
break;
|
||||
case 'u':
|
||||
consume();
|
||||
consume();
|
||||
consume();
|
||||
consume();
|
||||
// FIXME: This is obviously not correct, but we don't have non-ASCII support so meh.
|
||||
buffer.append('?');
|
||||
break;
|
||||
case 'u': {
|
||||
StringBuilder sb;
|
||||
sb.append(consume());
|
||||
sb.append(consume());
|
||||
sb.append(consume());
|
||||
sb.append(consume());
|
||||
|
||||
bool ok;
|
||||
u32 codepoint = AK::StringUtils::convert_to_uint_from_hex(sb.to_string(), ok);
|
||||
if (ok && codepoint < 128) {
|
||||
buffer.append((char)codepoint);
|
||||
} else {
|
||||
// FIXME: This is obviously not correct, but we don't have non-ASCII support so meh.
|
||||
buffer.append('?');
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
buffer.append(escaped_ch);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue