playlist/xspf: concatenate multiple CharacterData fragments

Closes https://github.com/MusicPlayerDaemon/MPD/issues/781
This commit is contained in:
Max Kellermann 2020-03-11 20:44:16 +01:00
parent e0a8fd398c
commit c45f113856
2 changed files with 17 additions and 6 deletions

2
NEWS
View File

@ -1,6 +1,8 @@
ver 0.21.21 (not yet released)
* configuration
- fix bug in "metadata_to_use" setting
* playlist
- xspf: fix corrupt tags in the presence of XML entities
* archive
- iso9660: skip empty file names to work around libcdio bug
* decoder

View File

@ -61,6 +61,8 @@ struct XspfParser {
std::string location;
TagBuilder tag_builder;
std::string value;
};
static constexpr struct tag_table xspf_tag_elements[] = {
@ -81,6 +83,7 @@ xspf_start_element(void *user_data, const XML_Char *element_name,
gcc_unused const XML_Char **atts)
{
XspfParser *parser = (XspfParser *)user_data;
parser->value.clear();
switch (parser->state) {
case XspfParser::ROOT:
@ -154,10 +157,21 @@ xspf_end_element(void *user_data, const XML_Char *element_name)
break;
case XspfParser::TAG:
if (!parser->value.empty())
parser->tag_builder.AddItem(parser->tag_type,
StringView(parser->value.data(),
parser->value.length()));
parser->state = XspfParser::TRACK;
break;
case XspfParser::LOCATION:
parser->location = std::move(parser->value);
parser->state = XspfParser::TRACK;
break;
}
parser->value.clear();
}
static void XMLCALL
@ -173,13 +187,8 @@ xspf_char_data(void *user_data, const XML_Char *s, int len)
break;
case XspfParser::TAG:
parser->tag_builder.AddItem(parser->tag_type,
StringView(s, len));
break;
case XspfParser::LOCATION:
parser->location.assign(s, len);
parser->value.append(s, len);
break;
}
}