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>
This commit is contained in:
Miika Turkia 2013-03-26 21:59:22 +02:00 committed by Dirk Hohndel
parent 61473080a5
commit ed9c9051d2

View file

@ -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);