mirror of
https://github.com/mpv-player/mpv
synced 2025-03-06 22:28:01 +00:00
json: fix UTF-8 handling
We escape only characters below 32, plus " and \. UTF-8 should be apssed through verbatim. Since char can be signed (and usually is), the check broke and happened to escape UTF-8 encoded bytes too. This broke UTF-8 completely. Note that we don't check for broken or invalid UTF-8, such as described both in the client API and IPC docs. Fixes #1874.
This commit is contained in:
parent
43b6b376dc
commit
f77e3cbf0c
@ -218,11 +218,11 @@ int json_parse(void *ta_parent, struct mpv_node *dst, char **src, int max_depth)
|
||||
|
||||
#define APPEND(b, s) bstr_xappend(NULL, (b), bstr0(s))
|
||||
|
||||
static void write_json_str(bstr *b, char *str)
|
||||
static void write_json_str(bstr *b, unsigned char *str)
|
||||
{
|
||||
APPEND(b, "\"");
|
||||
while (1) {
|
||||
char *cur = str;
|
||||
unsigned char *cur = str;
|
||||
while (cur[0] && cur[0] >= 32 && cur[0] != '"' && cur[0] != '\\')
|
||||
cur++;
|
||||
if (!cur[0])
|
||||
|
Loading…
Reference in New Issue
Block a user