[PATCH] Check if DLD contains non-ascii characters
Miika Turkia
miika.turkia at gmail.com
Tue Mar 26 12:59:22 PDT 2013
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.
Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
I wonder if there is a function available to do all this in one go. But
this patch gets the job done...
---
parse-xml.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/parse-xml.c b/parse-xml.c
index 707ac27..4701a17 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);
--
1.7.9.5
More information about the subsurface
mailing list