Skip to content

Commit ad29afd

Browse files
committed
Document xsl:keys handling better in ext/xsl
1 parent ec778c0 commit ad29afd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/xsl/xsltprocessor.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,13 @@ PHP_METHOD(XSLTProcessor, importStylesheet)
176176
clone_docu = zend_is_true(cloneDocu);
177177
zend_string_release_ex(member, 0);
178178
if (clone_docu == 0) {
179-
/* check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation */
179+
/* Check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation.
180+
* xsl:key elements may only occur at the top level. Furthermore, all elements at the top level must be in a
181+
* namespace (if not, then the stylesheet is not well-formed and this function will have returned false earlier). */
180182
nodep = xmlDocGetRootElement(sheetp->doc);
181183
if (nodep && (nodep = nodep->children)) {
182184
while (nodep) {
185+
ZEND_ASSERT(nodep->ns != NULL);
183186
if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, (const xmlChar *) "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
184187
intern->hasKeys = true;
185188
break;

0 commit comments

Comments
 (0)