From ed9c9051d297056f166d7e4a3bb427d3d86b2cf1 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Tue, 26 Mar 2013 21:59:22 +0200 Subject: 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 Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- parse-xml.c | 5 +++++ 1 file changed, 5 insertions(+) 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); -- cgit v1.2.3-70-g09d2