mirror of https://github.com/mpv-player/mpv
cue: strip quotes and leading whitespace from tags
If tags like TITLE have the whole parameter in " quotes, strip them. Also remove the leading whitespace, since even with a single space it was always included. Fixes #5462.
This commit is contained in:
parent
eaa97daf65
commit
7f3c7100d5
12
demux/cue.c
12
demux/cue.c
|
@ -75,7 +75,7 @@ static enum cue_command read_cmd(struct bstr *data, struct bstr *out_params)
|
||||||
if (rest.len && !strchr(WHITESPACE, rest.start[0]))
|
if (rest.len && !strchr(WHITESPACE, rest.start[0]))
|
||||||
continue;
|
continue;
|
||||||
if (out_params)
|
if (out_params)
|
||||||
*out_params = rest;
|
*out_params = bstr_lstrip(rest);
|
||||||
return cue_command_strings[n].command;
|
return cue_command_strings[n].command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,14 @@ static char *read_quoted(void *talloc_ctx, struct bstr *data)
|
||||||
return bstrto0(talloc_ctx, res);
|
return bstrto0(talloc_ctx, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct bstr strip_quotes(struct bstr data)
|
||||||
|
{
|
||||||
|
bstr s = data;
|
||||||
|
if (bstr_eatstart0(&s, "\"") && bstr_eatend0(&s, "\""))
|
||||||
|
return s;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
// Read a 2 digit unsigned decimal integer.
|
// Read a 2 digit unsigned decimal integer.
|
||||||
// Return -1 on failure.
|
// Return -1 on failure.
|
||||||
static int read_int_2(struct bstr *data)
|
static int read_int_2(struct bstr *data)
|
||||||
|
@ -193,7 +201,7 @@ struct cue_file *mp_parse_cue(struct bstr data)
|
||||||
[CUE_PERFORMER] = "performer",
|
[CUE_PERFORMER] = "performer",
|
||||||
};
|
};
|
||||||
struct mp_tags *tags = cur_track ? cur_track->tags : f->tags;
|
struct mp_tags *tags = cur_track ? cur_track->tags : f->tags;
|
||||||
mp_tags_set_bstr(tags, bstr0(metanames[cmd]), param);
|
mp_tags_set_bstr(tags, bstr0(metanames[cmd]), strip_quotes(param));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CUE_INDEX: {
|
case CUE_INDEX: {
|
||||||
|
|
Loading…
Reference in New Issue