[libxml2] Fix parsing of NCNames in XPath



commit e28939036281969477d3913a51c001bb7635fe54
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Thu Apr 21 19:19:23 2016 +0200

    Fix parsing of NCNames in XPath
    
    The NCName parser would allow any NameChar as start character. For
    example, the following XPath expressions would compile:
    
        self::-abc
        self::0abc
        self::.abc

 result/XPath/expr/base |    4 ++++
 test/XPath/expr/base   |    1 +
 xpath.c                |    2 +-
 3 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/result/XPath/expr/base b/result/XPath/expr/base
index 3552866..d308a92 100644
--- a/result/XPath/expr/base
+++ b/result/XPath/expr/base
@@ -18,3 +18,7 @@ Object is a number : 11
 ========================
 Expression: (1+2)*(3+4)
 Object is a number : 21
+
+========================
+Expression: self::-name
+Object is empty (NULL)
diff --git a/test/XPath/expr/base b/test/XPath/expr/base
index 9aaed4f..0be4871 100644
--- a/test/XPath/expr/base
+++ b/test/XPath/expr/base
@@ -3,3 +3,4 @@
 2*3
 1+2*3+4
 (1+2)*(3+4)
+self::-name
diff --git a/xpath.c b/xpath.c
index 5620861..7d03454 100644
--- a/xpath.c
+++ b/xpath.c
@@ -9996,7 +9996,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
         (c == '[') || (c == ']') || (c == '@') || /* accelerators */
         (c == '*') || /* accelerators */
        (!IS_LETTER(c) && (c != '_') &&
-         ((qualified) && (c != ':')))) {
+         ((!qualified) || (c != ':')))) {
        return(NULL);
     }
 


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