summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2022-02-04 14:00:09 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2022-02-04 14:00:09 +0100
commit5408c10c37c79f3f4b55700b9d89edb79ff5f9a5 (patch)
tree4ce7f74ffe9a6530d7e280e50ff5da197e677c25
parent1c7d91abe404333cb29f547ae7e844467befc53a (diff)
downloadlibxml2-5408c10c37c79f3f4b55700b9d89edb79ff5f9a5.tar.gz
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.
-rw-r--r--result/XPath/xptr/issue289base7
-rw-r--r--test/XPath/docs/issue2893
-rw-r--r--test/XPath/xptr/issue289base1
-rw-r--r--xpointer.c26
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 {