summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2013-03-26 21:59:22 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-26 13:15:38 -0700
commited9c9051d297056f166d7e4a3bb427d3d86b2cf1 (patch)
tree23d36a178c7f62ba4354fe30408b09857d141aea /parse-xml.c
parent61473080a5c76b6f5ee3a566ae4f795efd6ac3f4 (diff)
downloadsubsurface-ed9c9051d297056f166d7e4a3bb427d3d86b2cf1.tar.gz
Check if DLD contains non-ascii characters
Valid divelogs.de export might contain non-ascii characters in CDATA fields as long as these characters are found in iso-8859-1. So we'll have to test to make sure the content is fully ascii before calling xmlStringLenDecodeEntities to decode possible character references. Acked-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 707ac271d..4701a173a 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1545,6 +1545,11 @@ const char *preprocess_divelog_de(const char *buffer)
if (ret) {
xmlParserCtxtPtr ctx;
char buf[] = "";
+ int i;
+
+ for (i = 0; i < strlen(ret); ++i)
+ if (!isascii(ret[i]))
+ return buffer;
ctx = xmlCreateMemoryParserCtxt(buf, sizeof(buf));
ret = xmlStringLenDecodeEntities(ctx, ret, strlen(ret), XML_SUBSTITUTE_REF, 0, 0, 0);