playlist/asx: concatenate multiple CharacterData fragments

Similar to c45f113856
This commit is contained in:
Max Kellermann 2020-03-12 21:07:37 +01:00
parent 33694642bd
commit 82743dfd02
2 changed files with 11 additions and 3 deletions

2
NEWS
View File

@ -2,7 +2,7 @@ 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
- asx, xspf: fix corrupt tags in the presence of XML entities
* archive
- iso9660: skip empty file names to work around libcdio bug
* decoder

View File

@ -59,6 +59,8 @@ struct AsxParser {
TagBuilder tag_builder;
std::string value;
AsxParser()
:state(ROOT) {}
@ -77,6 +79,7 @@ asx_start_element(void *user_data, const XML_Char *element_name,
const XML_Char **atts)
{
AsxParser *parser = (AsxParser *)user_data;
parser->value.clear();
switch (parser->state) {
case AsxParser::ROOT:
@ -128,9 +131,15 @@ asx_end_element(void *user_data, const XML_Char *element_name)
break;
case AsxParser::TAG:
if (!parser->value.empty())
parser->tag_builder.AddItem(parser->tag_type,
StringView(parser->value.data(),
parser->value.length()));
parser->state = AsxParser::ENTRY;
break;
}
parser->value.clear();
}
static void XMLCALL
@ -144,8 +153,7 @@ asx_char_data(void *user_data, const XML_Char *s, int len)
break;
case AsxParser::TAG:
parser->tag_builder.AddItem(parser->tag_type,
StringView(s, len));
parser->value.append(s, len);
break;
}
}