[PATCH] Check if DLD contains non-ascii characters

Dirk Hohndel dirk at hohndel.org
Tue Mar 26 13:15:23 PDT 2013


Miika Turkia <miika.turkia at gmail.com> writes:

> 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.

So what happens if we have both ä and #&1023; in the CDATA section?

/D

> 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
>
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface



More information about the subsurface mailing list