[libxslt] xsl:template without name and match attributes should not be allowed



commit e3577d4897677d775e6c48d5172089fade95b886
Author: Nikolai Weibull <now disu se>
Date:   Mon Oct 28 09:10:35 2019 +0100

    xsl:template without name and match attributes should not be allowed
    
    libxslt allows for an xsl:template to be created without name or match attribute.  This isn’t allowed by 
the standard and sometimes my colleagues forget and then wonder why things don’t work :-).
    
    A simple check in xsltAddTemplate would suffice, for example,

 libxslt/pattern.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/libxslt/pattern.c b/libxslt/pattern.c
index 8e4cd4a2..c6496732 100644
--- a/libxslt/pattern.c
+++ b/libxslt/pattern.c
@@ -2156,8 +2156,15 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
         xmlHashAddEntry2(style->namedTemplates, cur->name, cur->nameURI, cur);
     }
 
-    if (cur->match == NULL)
+    if (cur->match == NULL) {
+            if (cur->name == NULL) {
+                xsltTransformError(NULL, style, cur->elem,
+                    "xsl:template: need to specify match or name attribute\n");
+                style->errors++;
+                return(-1);
+            }
        return(0);
+    }
 
     priority = cur->priority;
     pat = xsltCompilePatternInternal(cur->match, style->doc, cur->elem,


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