[mpd] Sanitize newline characters in ID3 tag values (#1615)

Fixes https://github.com/owntone/owntone-server/issues/1613
This commit is contained in:
Marek Skrobacki 2023-08-12 22:57:28 +01:00 committed by GitHub
parent 2ad680a96b
commit 469fcf6707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2721,6 +2721,27 @@ mpd_command_findadd(struct evbuffer *evbuf, int argc, char **argv, char **errmsg
return 0;
}
/*
* Some MPD clients crash if the tag value includes the newline character.
* While they should normally not be included in most ID3 tags, they sometimes
* are, so we just change them to space. See #1613 for more details.
*/
static void
sanitize_value(char **strval)
{
char *ptr = *strval;
while(*ptr != '\0')
{
if(*ptr == '\n')
{
*ptr = ' ';
}
ptr++;
}
}
static int
mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, struct mpd_client_ctx *ctx)
{
@ -2784,6 +2805,7 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, s
if (!(*strval) || (**strval == '\0'))
continue;
sanitize_value(strval);
evbuffer_add_printf(evbuf,
"%s: %s\n",
tagtype->tag,