Skip to content

Commit

Permalink
[mpd] Sanitize newline characters in ID3 tag values (#1615)
Browse files Browse the repository at this point in the history
Fixes #1613
  • Loading branch information
skrobul authored Aug 12, 2023
1 parent 2ad680a commit 469fcf6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/mpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 469fcf6

Please sign in to comment.