[libxslt] Test recursion in EXSLT dynamic functions



commit b7994c3b7ab83b502f4298ab4abb10fb183f7ed4
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Thu Jul 28 20:58:02 2022 +0200

    Test recursion in EXSLT dynamic functions
    
    This was fixed in libxml2 here:
    
    https://gitlab.gnome.org/GNOME/libxml2/-/commit/677a42645ef22b5a50741bad5facf9d8a8bc6d21
    
    Found by OSS-Fuzz.

 tests/exslt/dynamic/Makefile.am   | 10 ++++++++--
 tests/exslt/dynamic/recursion.err |  7 +++++++
 tests/exslt/dynamic/recursion.out |  2 ++
 tests/exslt/dynamic/recursion.xml |  4 ++++
 tests/exslt/dynamic/recursion.xsl | 21 +++++++++++++++++++++
 5 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/tests/exslt/dynamic/Makefile.am b/tests/exslt/dynamic/Makefile.am
index 84ebb5f8..0100dc9f 100644
--- a/tests/exslt/dynamic/Makefile.am
+++ b/tests/exslt/dynamic/Makefile.am
@@ -3,8 +3,14 @@
 $(top_builddir)/xsltproc/xsltproc:
        @(cd ../../../xsltproc ; $(MAKE) xsltproc)
 
-EXTRA_DIST =                                                   \
-  dynmap.out     dynmap.xml     dynmap.xsl
+EXTRA_DIST = \
+    dynmap.out \
+    dynmap.xml \
+    dynmap.xsl \
+    recursion.err \
+    recursion.out \
+    recursion.xml \
+    recursion.xsl
 
 CLEANFILES = .memdump
 
diff --git a/tests/exslt/dynamic/recursion.err b/tests/exslt/dynamic/recursion.err
new file mode 100644
index 00000000..02fdd564
--- /dev/null
+++ b/tests/exslt/dynamic/recursion.err
@@ -0,0 +1,7 @@
+XPath error : Recursion limit exceeded
+dyn:evaluate(.)
+             ^
+dyn:evaluate() : unable to evaluate expression 'dyn:evaluate(.)'
+XPath error : Recursion limit exceeded
+dyn:map(., .)
+        ^
diff --git a/tests/exslt/dynamic/recursion.out b/tests/exslt/dynamic/recursion.out
new file mode 100644
index 00000000..e829790a
--- /dev/null
+++ b/tests/exslt/dynamic/recursion.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<result/>
diff --git a/tests/exslt/dynamic/recursion.xml b/tests/exslt/dynamic/recursion.xml
new file mode 100644
index 00000000..5deb806b
--- /dev/null
+++ b/tests/exslt/dynamic/recursion.xml
@@ -0,0 +1,4 @@
+<doc>
+    <eval>dyn:evaluate(.)</eval>
+    <map>dyn:map(., .)</map>
+</doc>
diff --git a/tests/exslt/dynamic/recursion.xsl b/tests/exslt/dynamic/recursion.xsl
new file mode 100644
index 00000000..55bd8dc9
--- /dev/null
+++ b/tests/exslt/dynamic/recursion.xsl
@@ -0,0 +1,21 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
+ xmlns:dyn="http://exslt.org/dynamic";
+ exclude-result-prefixes="dyn"
+>
+
+<xsl:template match="/doc">
+  <result>
+    <xsl:apply-templates select="*"/>
+  </result>
+</xsl:template>
+
+<xsl:template match="eval">
+  <xsl:value-of select="dyn:evaluate(.)"/>
+</xsl:template>
+
+<xsl:template match="map">
+  <xsl:value-of select="dyn:map(., .)"/>
+</xsl:template>
+
+</xsl:stylesheet>
+


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