Bug #2644
closedhtsmsg_xml_deserialize fails when <!DOCTYPE> exist in xmltv.xml
100%
Description
While testing a network tuner (VBox) I found this issue with the auto generated xmltv.xml which includes <!DOCTYPE>, see attached file.
I'm sending the xmltv.xml through the xmltv.sock with "cat xmltv.xml | socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epggrab/xmltv.sock"
Log output
tvheadend[4025]: xmltv: htsmsg_xml_deserialize error Unknown syntatic element: <!DOCTYPE tv
tvheadend[4025]: xmltv: failed to read data
Files
Updated by dhead 666 over 11 years ago
I'm not sure if to call it resolved but the reason for the issue is probably because the file starting with the following hidden characters:
M-oM-;M-?
Updated by Jaroslav Kysela over 11 years ago
It looks like UTF-8 BOM: http://unicode.org/faq/utf_bom.html
Updated by Jaroslav Kysela over 11 years ago
Does this help for you ?
diff --git a/src/htsmsg_xml.c b/src/htsmsg_xml.c
index d1ba7d5..81ff53c 100644
--- a/src/htsmsg_xml.c
+++ b/src/htsmsg_xml.c
@@ -833,6 +833,10 @@ htsmsg_xml_deserialize(char *src, char *errbuf, size_t errbufsize)
xp.xp_encoding = XML_ENCODING_UTF8;
LIST_INIT(&xp.xp_namespaces);
+ /* check for UTF-8 BOM */
+ if(src[0] == 0xef && src[1] == 0xbb && src[2] == 0xbf)
+ memmove(src, src + 3, strlen(src) - 2);
+
if((src = htsmsg_parse_prolog(&xp, src)) == NULL)
goto err;
Updated by dhead 666 over 11 years ago
The patch works perfectly :)
Updated by Jaroslav Kysela over 11 years ago
- Status changed from New to Fixed
- % Done changed from 0 to 100
Applied in changeset commit:tvheadend|3c0a2798251a4c40d1e89b6cf835f465438d4d1d.