[libxml2] Don't normalize namespace URIs in XPointer xmlns() scheme



commit 5408c10c37c79f3f4b55700b9d89edb79ff5f9a5
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Fri Feb 4 14:00:09 2022 +0100

    Don't normalize namespace URIs in XPointer xmlns() scheme
    
    Namespace URIs should be compared without escaping or unescaping:
    
    https://www.w3.org/TR/REC-xml-names/#NSNameComparison
    
    Fixes #289.

 result/XPath/xptr/issue289base |  7 +++++++
 test/XPath/docs/issue289       |  3 +++
 test/XPath/xptr/issue289base   |  1 +
 xpointer.c                     | 26 +-------------------------
 4 files changed, 12 insertions(+), 25 deletions(-)
---
diff --git a/result/XPath/xptr/issue289base b/result/XPath/xptr/issue289base
new file mode 100644
index 00000000..ec56aef2
--- /dev/null
+++ b/result/XPath/xptr/issue289base
@@ -0,0 +1,7 @@
+
+========================
+Expression: xmlns(b=abc://d/e:f) xpointer(/b:rootB)
+Object is a Node Set :
+Set contains 1 nodes:
+1  ELEMENT rootB
+    default namespace href=abc://d/e:f
diff --git a/test/XPath/docs/issue289 b/test/XPath/docs/issue289
new file mode 100644
index 00000000..67bb1140
--- /dev/null
+++ b/test/XPath/docs/issue289
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<rootB xmlns="abc://d/e:f">
+</rootB>
diff --git a/test/XPath/xptr/issue289base b/test/XPath/xptr/issue289base
new file mode 100644
index 00000000..716a92fd
--- /dev/null
+++ b/test/XPath/xptr/issue289base
@@ -0,0 +1 @@
+xmlns(b=abc://d/e:f) xpointer(/b:rootB)
diff --git a/xpointer.c b/xpointer.c
index fe2fca5a..afeaa2ec 100644
--- a/xpointer.c
+++ b/xpointer.c
@@ -1040,8 +1040,6 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
        const xmlChar *oldBase = ctxt->base;
        const xmlChar *oldCur = ctxt->cur;
        xmlChar *prefix;
-       xmlChar *URI;
-       xmlURIPtr value;
 
        ctxt->cur = ctxt->base = buffer;
         prefix = xmlXPathParseNCName(ctxt);
@@ -1063,32 +1061,10 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
        }
        NEXT;
        SKIP_BLANKS;
-       /* @@ check escaping in the XPointer WD */
 
-       value = xmlParseURI((const char *)ctxt->cur);
-       if (value == NULL) {
-            ctxt->base = oldBase;
-            ctxt->cur = oldCur;
-           xmlFree(prefix);
-           xmlFree(buffer);
-           xmlFree(name);
-           XP_ERROR(XPTR_SYNTAX_ERROR);
-       }
-       URI = xmlSaveUri(value);
-       xmlFreeURI(value);
-       if (URI == NULL) {
-            ctxt->base = oldBase;
-            ctxt->cur = oldCur;
-           xmlFree(prefix);
-           xmlFree(buffer);
-           xmlFree(name);
-           XP_ERROR(XPATH_MEMORY_ERROR);
-       }
-
-       xmlXPathRegisterNs(ctxt->context, prefix, URI);
+       xmlXPathRegisterNs(ctxt->context, prefix, ctxt->cur);
         ctxt->base = oldBase;
         ctxt->cur = oldCur;
-       xmlFree(URI);
        xmlFree(prefix);
 #endif /* XPTR_XMLNS_SCHEME */
     } else {


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