diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-09-02 09:05:31 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-09-03 09:30:34 -0700 |
commit | 5eda1c0e39b7c5e4e68ec68596cb023e37503ba7 (patch) | |
tree | f5e445464c5a01f4423dcb45ca9f6182c29278fc | |
parent | 836111da982a6580e314d8297c47ad96be5065a2 (diff) | |
download | subsurface-5eda1c0e39b7c5e4e68ec68596cb023e37503ba7.tar.gz |
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>
-rw-r--r-- | core/parse-xml.c | 4 | ||||
-rw-r--r-- | core/save-xml.c | 2 | ||||
-rw-r--r-- | core/uploadDiveLogsDE.cpp | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c index 5b9abc341..d3a21cc8f 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -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); diff --git a/core/save-xml.c b/core/save-xml.c index 3836ea35c..a82fcef4b 100644 --- a/core/save-xml.c +++ b/core/save-xml.c @@ -865,7 +865,7 @@ static int export_dives_xslt_doit(const char *filename, struct xml_params *param * transform it to selected export format, finally dumping * the XML into a character buffer. */ - doc = xmlReadMemory(buf.buffer, buf.len, "divelog", NULL, XML_PARSE_HUGE); + doc = xmlReadMemory(buf.buffer, buf.len, "divelog", NULL, XML_PARSE_HUGE | XML_PARSE_RECOVER); free_buffer(&buf); if (!doc) return report_error("Failed to read XML memory"); diff --git a/core/uploadDiveLogsDE.cpp b/core/uploadDiveLogsDE.cpp index 18377698d..07f799edf 100644 --- a/core/uploadDiveLogsDE.cpp +++ b/core/uploadDiveLogsDE.cpp @@ -142,7 +142,7 @@ bool uploadDiveLogsDE::prepareDives(const QString &tempfile, bool selected) * transform it to divelogs.de format, finally dumping * the XML into a character buffer. */ - xmlDoc *doc = xmlReadMemory(mb.buffer, mb.len, "divelog", NULL, 0); + xmlDoc *doc = xmlReadMemory(mb.buffer, mb.len, "divelog", NULL, XML_PARSE_HUGE | XML_PARSE_RECOVER); if (!doc) { qWarning() << errPrefix << "could not parse back into memory the XML file we've just created!"; report_error(tr("internal error").toUtf8()); |