Re: [xslt] Release candidate 1 of libxslt-1.1.27



On 05/09/2012 15:59, Daniel Veillard wrote:
   I tagged the git and pushed a tarball of the rc1 to:
    ftp://xmlsoft.org/libxslt/

Please give it a try, I will probably commit some pending patches,
and then push a final release next week,

Here are my remaining patches rebased against master.

0001-Null-terminate-result-string-of-cry-rc4_decrypt
Fix for bug #675917

0002-Test-for-bug-680920
Another test case for bug #680920

0003-Add-new-tests-to-EXTRA_DIST

0004-Reserved-namespaces-in-xsl-element-and-xsl-attribute
Better version of my patch for bug #587360. Also fixes xsl:element.

0005-Fix-handling-of-names-in-xsl-attribute
Another patch to fix the handling of names in xsl:attribute if I understand the spec correctly.

Nick


>From a8e8fd6be707477f44aabafbc5ec5424894baaae Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Tue, 31 Jul 2012 21:27:51 +0200
Subject: [PATCH 1/5] Null-terminate result string of cry:rc4_decrypt

Bug #675917
---
 libexslt/crypto.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libexslt/crypto.c b/libexslt/crypto.c
index e2700d6..42ac6c5 100644
--- a/libexslt/crypto.c
+++ b/libexslt/crypto.c
@@ -752,7 +752,7 @@ exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
     ret_len = exsltCryptoHex2Bin (str, str_len, bin, bin_len);
 
 /* decrypt the binary blob */
-    ret = xmlMallocAtomic (ret_len);
+    ret = xmlMallocAtomic (ret_len + 1);
     if (ret == NULL) {
 	xsltTransformError(tctxt, NULL, tctxt->inst,
 	    "exsltCryptoRc4EncryptFunction: Failed to allocate result\n");
@@ -761,6 +761,7 @@ exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
 	goto done;
     }
     PLATFORM_RC4_DECRYPT (ctxt, padkey, bin, ret_len, ret, ret_len);
+    ret[ret_len] = 0;
 
     xmlXPathReturnString (ctxt, ret);
 
-- 
1.7.10.4

>From dd79fd86d160446fbda262f4cb86b9ace75b3ba1 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Tue, 31 Jul 2012 23:32:05 +0200
Subject: [PATCH 2/5] Test for bug #680920

---
 tests/docs/bug-178.xml    |    1 +
 tests/general/Makefile.am |    1 +
 tests/general/bug-178.out |    2 ++
 tests/general/bug-178.xsl |   18 ++++++++++++++++++
 4 files changed, 22 insertions(+)
 create mode 100644 tests/docs/bug-178.xml
 create mode 100644 tests/general/bug-178.out
 create mode 100644 tests/general/bug-178.xsl

diff --git a/tests/docs/bug-178.xml b/tests/docs/bug-178.xml
new file mode 100644
index 0000000..69d62f2
--- /dev/null
+++ b/tests/docs/bug-178.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index f7fdea9..523183b 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -181,6 +181,7 @@ EXTRA_DIST = \
     bug-171.out bug-171.xsl \
     bug-172.out bug-172.xsl \
     bug-173.out bug-173.xsl \
+    bug-178.out bug-178.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
     itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-178.out b/tests/general/bug-178.out
new file mode 100644
index 0000000..e829790
--- /dev/null
+++ b/tests/general/bug-178.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<result/>
diff --git a/tests/general/bug-178.xsl b/tests/general/bug-178.xsl
new file mode 100644
index 0000000..aab57a4
--- /dev/null
+++ b/tests/general/bug-178.xsl
@@ -0,0 +1,18 @@
+<xsl:stylesheet
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+	xmlns:func = "http://exslt.org/functions";
+	version="1.0" extension-element-prefixes="func">
+
+<func:function name="func:uaf">
+	<xsl:text/>
+	<func:result/>
+</func:function>
+
+<xsl:template match="/">
+        <result>
+	        <xsl:value-of select="func:uaf()"/>
+        </result>
+</xsl:template>
+
+</xsl:stylesheet>
+
-- 
1.7.10.4

>From 749a2afb5dc3bf66c2d3c5f7dc4fdef12b2dee46 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Wed, 15 Aug 2012 23:10:16 +0200
Subject: [PATCH 3/5] Add new tests to EXTRA_DIST

---
 tests/general/Makefile.am |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index 523183b..c9b2036 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -181,6 +181,9 @@ EXTRA_DIST = \
     bug-171.out bug-171.xsl \
     bug-172.out bug-172.xsl \
     bug-173.out bug-173.xsl \
+    bug-174.out bug-174.xsl bug-174.err \
+    bug-175.out bug-175.xsl bug-175.err \
+    bug-176.out bug-176.xsl \
     bug-178.out bug-178.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
-- 
1.7.10.4

>From eb79f0a35f082fe662854a37ecca8d8d7f52d231 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Wed, 15 Aug 2012 23:50:22 +0200
Subject: [PATCH 4/5] Reserved namespaces in xsl:element and xsl:attribute

Correct handling of 'xml' and 'xmlns' namespaces in xsl:element and
xsl:attribute. Fixes bug #587360.
---
 libxslt/attributes.c      |   14 ++++++++++++-
 libxslt/transform.c       |   48 ++++++++++++++++++++++++++++-----------------
 tests/docs/bug-177.xml    |    1 +
 tests/general/Makefile.am |    1 +
 tests/general/bug-177.out |    2 ++
 tests/general/bug-177.xsl |    7 +++++++
 6 files changed, 54 insertions(+), 19 deletions(-)
 create mode 100644 tests/docs/bug-177.xml
 create mode 100644 tests/general/bug-177.out
 create mode 100644 tests/general/bug-177.xsl

diff --git a/libxslt/attributes.c b/libxslt/attributes.c
index 11d558b..a584d22 100644
--- a/libxslt/attributes.c
+++ b/libxslt/attributes.c
@@ -822,7 +822,19 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt,
 	    if ((tmpNsName != NULL) && (tmpNsName[0] != 0))
 		nsName = xmlDictLookup(ctxt->dict, BAD_CAST tmpNsName, -1);
 	    xmlFree(tmpNsName);		
-	};	    
+	}
+
+        if (xmlStrEqual(nsName, BAD_CAST "http://www.w3.org/2000/xmlns/";)) {
+            xsltTransformError(ctxt, NULL, inst,
+                "xsl:attribute: Namespace http://www.w3.org/2000/xmlns/ "
+                "forbidden.\n");
+            goto error;
+        }
+        if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
+            prefix = BAD_CAST "xml";
+        } else if (xmlStrEqual(prefix, BAD_CAST "xml")) {
+            prefix = NULL;
+        }
     } else if (prefix != NULL) {
 	/*
 	* SPEC XSLT 1.0:
diff --git a/libxslt/transform.c b/libxslt/transform.c
index bc6d851..213422d 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -3978,14 +3978,6 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
 	}
 	name = xsltSplitQName(ctxt->dict, prop, &prefix);
 	xmlFree(prop);
-	if ((prefix != NULL) &&
-	    (!xmlStrncasecmp(prefix, (xmlChar *)"xml", 3)))
-	{
-	    /*
-	    * TODO: Should we really disallow an "xml" prefix?
-	    */
-	    goto error;
-	}
     } else {
 	/*
 	* The "name" value was static.
@@ -4040,8 +4032,20 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
 	    if ((tmpNsName != NULL) && (tmpNsName[0] != 0))
 		nsName = xmlDictLookup(ctxt->dict, BAD_CAST tmpNsName, -1);
 	    xmlFree(tmpNsName);
-	};
-    } else {
+	}
+
+        if (xmlStrEqual(nsName, BAD_CAST "http://www.w3.org/2000/xmlns/";)) {
+            xsltTransformError(ctxt, NULL, inst,
+                "xsl:attribute: Namespace http://www.w3.org/2000/xmlns/ "
+                "forbidden.\n");
+            goto error;
+        }
+        if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
+            prefix = BAD_CAST "xml";
+        } else if (xmlStrEqual(prefix, BAD_CAST "xml")) {
+            prefix = NULL;
+        }
+    } else if (prefix != NULL) {
 	xmlNsPtr ns;
 	/*
 	* SPEC XSLT 1.0:
@@ -4056,13 +4060,11 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
 	    * TODO: Check this in the compilation layer in case it's a
 	    * static value.
 	    */
-	    if (prefix != NULL) {
-		xsltTransformError(ctxt, NULL, inst,
-		    "xsl:element: The QName '%s:%s' has no "
-		    "namespace binding in scope in the stylesheet; "
-		    "this is an error, since the namespace was not "
-		    "specified by the instruction itself.\n", prefix, name);
-	    }
+            xsltTransformError(ctxt, NULL, inst,
+                "xsl:element: The QName '%s:%s' has no "
+                "namespace binding in scope in the stylesheet; "
+                "this is an error, since the namespace was not "
+                "specified by the instruction itself.\n", prefix, name);
 	} else
 	    nsName = ns->href;
     }
@@ -4070,7 +4072,17 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
     * Find/create a matching ns-decl in the result tree.
     */
     if (nsName != NULL) {
-	copy->ns = xsltGetSpecialNamespace(ctxt, inst, nsName, prefix, copy);
+	if (xmlStrEqual(prefix, BAD_CAST "xmlns")) {
+            /* Don't use a prefix of "xmlns" */
+	    xmlChar *pref = xmlStrdup(BAD_CAST "ns_1");
+
+	    copy->ns = xsltGetSpecialNamespace(ctxt, inst, nsName, pref, copy);
+
+	    xmlFree(pref);
+	} else {
+	    copy->ns = xsltGetSpecialNamespace(ctxt, inst, nsName, prefix,
+		copy);
+	}
     } else if ((copy->parent != NULL) &&
 	(copy->parent->type == XML_ELEMENT_NODE) &&
 	(copy->parent->ns != NULL))
diff --git a/tests/docs/bug-177.xml b/tests/docs/bug-177.xml
new file mode 100644
index 0000000..69d62f2
--- /dev/null
+++ b/tests/docs/bug-177.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index c9b2036..e531870 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -184,6 +184,7 @@ EXTRA_DIST = \
     bug-174.out bug-174.xsl bug-174.err \
     bug-175.out bug-175.xsl bug-175.err \
     bug-176.out bug-176.xsl \
+    bug-177.out bug-177.xsl \
     bug-178.out bug-178.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
diff --git a/tests/general/bug-177.out b/tests/general/bug-177.out
new file mode 100644
index 0000000..91cd684
--- /dev/null
+++ b/tests/general/bug-177.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<doc xml:id="etc"/>
diff --git a/tests/general/bug-177.xsl b/tests/general/bug-177.xsl
new file mode 100644
index 0000000..52036f5
--- /dev/null
+++ b/tests/general/bug-177.xsl
@@ -0,0 +1,7 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+    <xsl:template match="/*">
+        <xsl:copy>
+            <xsl:attribute name="id" namespace="http://www.w3.org/XML/1998/namespace";>etc</xsl:attribute>
+        </xsl:copy>
+    </xsl:template>
+</xsl:stylesheet>
-- 
1.7.10.4

>From 578c5ffb17e9502dd0fe8f9df783a9f5cddb35da Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Thu, 16 Aug 2012 02:18:31 +0200
Subject: [PATCH 5/5] Fix handling of names in xsl:attribute

A prefix of 'xmlns' is actually allowed. It should simply be ignored
if a namespace is given. Without a namespace the lookup by prefix will
fail anyway.

What the spec doesn't allow is an attribute name of 'xmlns' which will
now be rejected.
---
 libxslt/attributes.c     |   31 +++++++++----------------------
 libxslt/preproc.c        |   25 ++++---------------------
 tests/REC/test-7.1.3.out |    2 +-
 3 files changed, 14 insertions(+), 44 deletions(-)

diff --git a/libxslt/attributes.c b/libxslt/attributes.c
index a584d22..ca81bdb 100644
--- a/libxslt/attributes.c
+++ b/libxslt/attributes.c
@@ -750,31 +750,19 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt,
 		"valid QName.\n", prop);
 	    /* we fall through to catch any further errors, if possible */
 	}
-	name = xsltSplitQName(ctxt->dict, prop, &prefix);
-	xmlFree(prop);
 
 	/*
-	* Reject a prefix of "xmlns".
+	* Reject a name of "xmlns".
 	*/
-	if ((prefix != NULL) &&
-	    (!xmlStrncasecmp(prefix, (xmlChar *) "xmlns", 5)))
-	{
-#ifdef WITH_XSLT_DEBUG_PARSING
-	    xsltGenericDebug(xsltGenericDebugContext,
-		"xsltAttribute: xmlns prefix forbidden\n");
-#endif
-	    /*
-	    * SPEC XSLT 1.0:
-	    *  "It is an error if the string that results from instantiating
-	    *  the attribute value template is not a QName or is the string
-	    *  xmlns. An XSLT processor may signal the error; if it does not
-	    *  signal the error, it must recover by not adding the attribute
-	    *  to the result tree."
-	    * TODO: Decide which way to go here.
-	    */
+	if (xmlStrEqual(prop, BAD_CAST "xmlns")) {
+            xsltTransformError(ctxt, NULL, inst,
+                "xsl:attribute: The effective name 'xmlns' is not allowed.\n");
+	    xmlFree(prop);
 	    goto error;
 	}
 
+	name = xsltSplitQName(ctxt->dict, prop, &prefix);
+	xmlFree(prop);
     } else {
 	/*
 	* The "name" value was static.
@@ -909,11 +897,10 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt,
 	* xsl:attribute can produce a scenario where the prefix is NULL,
 	* so generate a prefix.
 	*/
-	if (prefix == NULL) {
+	if ((prefix == NULL) || xmlStrEqual(prefix, BAD_CAST "xmlns")) {
 	    xmlChar *pref = xmlStrdup(BAD_CAST "ns_1");
 
-	    ns = xsltGetSpecialNamespace(ctxt, inst, nsName, BAD_CAST pref,
-		targetElem);
+	    ns = xsltGetSpecialNamespace(ctxt, inst, nsName, pref, targetElem);
 
 	    xmlFree(pref);
 	} else {
diff --git a/libxslt/preproc.c b/libxslt/preproc.c
index 4d483ff..ebd2fc1 100644
--- a/libxslt/preproc.c
+++ b/libxslt/preproc.c
@@ -1048,6 +1048,10 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
 		"xsl:attribute: The value '%s' of the attribute 'name' is "
 		"not a valid QName.\n", comp->name);
 	    style->errors++;
+        } else if (xmlStrEqual(comp->name, BAD_CAST "xmlns")) {
+	    xsltTransformError(NULL, style, inst,
+                "xsl:attribute: The attribute name 'xmlns' is not allowed.\n");
+	    style->errors++;
 	} else {
 	    const xmlChar *prefix = NULL, *name;
 
@@ -1081,27 +1085,6 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
 			style->errors++;
 		    }
 		}
-		if (!xmlStrncasecmp(prefix, (xmlChar *) "xmlns", 5)) {
-		    /*
-		    * SPEC XSLT 1.0:
-		    *  "It is an error if the string that results from
-		    *  instantiating the attribute value template is not a
-		    *  QName or is the string xmlns. An XSLT processor may
-		    *  signal the error; if it does not signal the error,
-		    *  it must recover by not adding the attribute to the
-		    *  result tree."
-		    *
-		    * Reject a prefix of "xmlns". Mark to be skipped.
-		    */
-		    comp->has_name = 0;
-		    
-#ifdef WITH_XSLT_DEBUG_PARSING
-		    xsltGenericDebug(xsltGenericDebugContext,
-			"xsltAttribute: xmlns prefix forbidden\n");
-#endif		    
-		    return;
-		}
-		
 	    }
 	}	
     }
diff --git a/tests/REC/test-7.1.3.out b/tests/REC/test-7.1.3.out
index dee0832..652fd9c 100644
--- a/tests/REC/test-7.1.3.out
+++ b/tests/REC/test-7.1.3.out
@@ -1,2 +1,2 @@
 <?xml version="1.0"?>
-<doc attr="value"/>
+<doc xmlns:ns_1="whatever" ns_1:xsl="http://www.w3.org/1999/XSL/Transform"; attr="value"/>
-- 
1.7.10.4



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