[xml] libxml2 version 2.9.0: xpath.c:xmlXPathStringEvalNumber() - not 100% fails to parse float with leading '+'



Dear creators of libxml2, 

I think I found a slight mistake in function xpath.c:xmlXPathStringEvalNumber()
of libxml2 version 2.9.0.

For data type "float" in xml files resp. xml schemas 
[1] states "The mantissa must be a decimal number."
[2] contains details: 
        An optional leading sign is allowed. 
        If the sign is omitted, "+" is assumed. 
and names "+100000.00" as valid example for a decimal.

In contrast when first non-whitespace-character of it's argument is a '+',
xpath.c:xmlXPathStringEvalNumber() stops parsing and return 0.0.

To make libxml2 conform to [1] I suggest the following change:

Replace 3 lines 10098 through 10100 (incl.) 
by the following 7 lines 

    if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-') && (*cur != '+')) {
        return(xmlXPathNAN);
    }
    if (*cur == '+') {
        isneg = 0;
        cur++;
    }


Please let me know, what you think about my proposal.

References 
[1] http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#float 
    3.2.4.1 Lexical representation
[2] http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#decimal 
    3.2.3.1 Lexical representation


With kind regards

Christoph Kuhnke

Entwicklung Fahrerassistenzsysteme

Elektrobit Automotive GmbH
Am Wolfsmantel 46
91056 Erlangen
Tel.: +49-9131-7701-7142
Mobil +49 (0) 172 8582839
christoph kuhnke elektrobit com

Im Auftrag der AUDI AG
I/EF-56, extern
85045 Ingolstadt
mailto:extern christoph kuhnke audi de



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]