From 7434b5569fe9bc858900e66580d17e3b80cb80fc Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sun, 12 May 2019 15:15:19 +0200
Subject: [PATCH 23/26] Fix insertion of xsl:fallback content

Fixes bug #730171: https://bugzilla.gnome.org/show_bug.cgi?id=730171
---
 libxslt/transform.c       |  2 ++
 tests/docs/bug-220.xml    |  1 +
 tests/general/bug-220.out |  2 ++
 tests/general/bug-220.xsl | 15 +++++++++++++++
 4 files changed, 20 insertions(+)
 create mode 100644 tests/docs/bug-220.xml
 create mode 100644 tests/general/bug-220.out
 create mode 100644 tests/general/bug-220.xsl

diff --git a/libxslt/transform.c b/libxslt/transform.c
index cf6ce67..b8dc363 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -2884,6 +2884,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
                 /*
                  * Search if there are fallbacks
                  */
+                ctxt->insert = insert;
                 child = cur->children;
                 while (child != NULL) {
                     if ((IS_XSLT_ELEM(child)) &&
@@ -2895,6 +2896,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
                     }
                     child = child->next;
                 }
+                ctxt->insert = oldInsert;
 
                 if (!found) {
                     xsltTransformError(ctxt, NULL, cur,
diff --git a/tests/docs/bug-220.xml b/tests/docs/bug-220.xml
new file mode 100644
index 0000000..69d62f2
--- /dev/null
+++ b/tests/docs/bug-220.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/general/bug-220.out b/tests/general/bug-220.out
new file mode 100644
index 0000000..abb48c3
--- /dev/null
+++ b/tests/general/bug-220.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<r><fallback/></r>
diff --git a/tests/general/bug-220.xsl b/tests/general/bug-220.xsl
new file mode 100644
index 0000000..cc4e3e0
--- /dev/null
+++ b/tests/general/bug-220.xsl
@@ -0,0 +1,15 @@
+<xsl:stylesheet
+    version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:ext="ext"
+    extension-element-prefixes="ext">
+<xsl:template match="/">
+    <r>
+        <ext:e>
+            <xsl:fallback><fallback/></xsl:fallback>
+            <ext:f/>
+        </ext:e>
+    </r>
+</xsl:template>
+</xsl:stylesheet>
+
-- 
1.8.3.1

