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

View File

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