parser: XML_PARSE_RECOVER to xmlReadMemory()

Due to changes in the handling of sensor-ids, invalid XMLs were
generated. In particular, these contained duplicate attributes
in the sample tags.

Even though these files shouldn't exist, let's try to parse
them anyway. Some data will be lost, but that's better than
not opening the file.

libxml2 can be told to try to recover from such petty(?) errors
by passing the XML_PARSE_RECOVER flag.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-09-02 09:05:31 +02:00 committed by Dirk Hohndel
parent 836111da98
commit 5eda1c0e39
3 changed files with 4 additions and 4 deletions

View file

@ -1745,9 +1745,9 @@ int parse_xml_buffer(const char *url, const char *buffer, int size,
state.sites = sites;
state.devices = devices;
state.filter_presets = filter_presets;
doc = xmlReadMemory(res, strlen(res), url, NULL, XML_PARSE_HUGE);
doc = xmlReadMemory(res, strlen(res), url, NULL, XML_PARSE_HUGE | XML_PARSE_RECOVER);
if (!doc)
doc = xmlReadMemory(res, strlen(res), url, "latin1", XML_PARSE_HUGE);
doc = xmlReadMemory(res, strlen(res), url, "latin1", XML_PARSE_HUGE | XML_PARSE_RECOVER);
if (res != buffer)
free((char *)res);