From a35b32f499643ffaadfc8dc0e312e5d5b736ddc6 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 31 Jan 2019 14:20:51 +0000
Subject: docbook-xsl: update to 1.79.2

---
 .../765567_non-recursive_string_subst.patch        | 32 ++++++++++++++
 abs/extra/docbook-xsl/PKGBUILD                     | 49 ++++++++++++----------
 abs/extra/docbook-xsl/docbook-xsl.install          | 18 ++++++--
 3 files changed, 74 insertions(+), 25 deletions(-)
 create mode 100644 abs/extra/docbook-xsl/765567_non-recursive_string_subst.patch

diff --git a/abs/extra/docbook-xsl/765567_non-recursive_string_subst.patch b/abs/extra/docbook-xsl/765567_non-recursive_string_subst.patch
new file mode 100644
index 0000000..ae845ad
--- /dev/null
+++ b/abs/extra/docbook-xsl/765567_non-recursive_string_subst.patch
@@ -0,0 +1,32 @@
+Description: use EXSLT "replace" function when available
+ A recursive implementation  of string.subst is problematic,
+ long strings with many matches will cause stack overflows.
+Author: Peter De Wachter <pdewacht@gmail.com>
+Bug-Debian: https://bugs.debian.org/750593
+
+--- docbook-xsl-1.78.1+dfsg.orig/docbook-xsl/lib/lib.xsl
++++ docbook-xsl-1.78.1+dfsg/docbook-xsl/lib/lib.xsl
+@@ -6,7 +6,11 @@
+ 
+      This module implements DTD-independent functions
+ 
+-     ******************************************************************** --><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
++     ******************************************************************** -->
++<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
++                xmlns:str="http://exslt.org/strings"
++                exclude-result-prefixes="str"
++                version="1.0">
+ 
+ <xsl:template name="dot.count">
+   <!-- Returns the number of "." characters in a string -->
+@@ -52,6 +56,9 @@
+   <xsl:param name="replacement"/>
+ 
+   <xsl:choose>
++    <xsl:when test="function-available('str:replace')">
++      <xsl:value-of select="str:replace($string, string($target), string($replacement))"/>
++    </xsl:when>
+     <xsl:when test="contains($string, $target)">
+       <xsl:variable name="rest">
+         <xsl:call-template name="string.subst">
+
diff --git a/abs/extra/docbook-xsl/PKGBUILD b/abs/extra/docbook-xsl/PKGBUILD
index aef4b1e..51712c6 100644
--- a/abs/extra/docbook-xsl/PKGBUILD
+++ b/abs/extra/docbook-xsl/PKGBUILD
@@ -1,35 +1,42 @@
-# $Id: PKGBUILD 162687 2012-06-27 22:24:21Z tomegun $
-# Maintainer: Tom Gundersen <teg@jklm.no>
+# Maintainer: Antonio Rojas <arojas@archlinux.org>
+# Contributor: Tom Gundersen <teg@jklm.no>
 # Contributor: Jan de Groot <jgc@archlinux.org>
 # Contributor: Sean Middleditch <elanthis@awesomeplay.com>
 # Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
 
 pkgname=docbook-xsl
-pkgver=1.77.1
-pkgrel=2
+pkgver=1.79.2
+pkgrel=4
 pkgdesc='XML stylesheets for Docbook-xml transformations'
-arch=('any')
-license=('custom')
-url='http://docbook.sourceforge.net/'
-depends=('libxml2' 'libxslt' 'docbook-xml')
+arch=(any)
+license=(custom)
+url='https://docbook.org/'
+depends=(libxml2 libxslt docbook-xml sed)
 install="$pkgname.install"
-source=("http://downloads.sourceforge.net/docbook/${pkgname}-${pkgver}.tar.bz2")
+source=("https://github.com/docbook/xslt10-stylesheets/releases/download/release%2F$pkgver/docbook-xsl-nons-$pkgver.tar.gz"
+        765567_non-recursive_string_subst.patch)
+sha256sums=('f89425b44e48aad24319a2f0d38e0cb6059fdc7dbaf31787c8346c748175ca8e'
+            '193ec26dcb37bdf12037ed4ea98d68bd550500c8e96b719685d76d7096c3f9b3')
+
+prepare() {
+  cd $pkgname-nons-$pkgver
+  patch -Np2 -i ../765567_non-recursive_string_subst.patch
+}
 
 package() {
-	cd ${srcdir}/${pkgname}-${pkgver}
+  cd $pkgname-nons-$pkgver
 
-	_pkgroot=${pkgdir}/usr/share/xml/docbook/xsl-stylesheets-${pkgver}
+  _pkgroot="$pkgdir"/usr/share/xml/docbook/xsl-stylesheets-$pkgver
 
-        install -dm755 ${_pkgroot}
-	install -m644 VERSION VERSION.xsl ${_pkgroot}
+  install -dm755 ${_pkgroot}
+  install -m644 VERSION VERSION.xsl ${_pkgroot}
 
-	for fn in assembly common eclipse epub epub3 fo highlighting html htmlhelp javahelp lib \
-                  manpages params profiling roundtrip template website xhtml xhtml-1_1 xhtml5; do
-		install -dm755 ${_pkgroot}/${fn}
-		install -m644 ${fn}/*.{xml,xsl,dtd,ent} ${_pkgroot}/${fn} || true  # ignore missing files
-	done
+  for fn in assembly common eclipse epub epub3 fo highlighting html htmlhelp javahelp lib \
+      manpages params profiling roundtrip template website xhtml xhtml-1_1 xhtml5; do
+          install -dm755 ${_pkgroot}/${fn}
+	  install -m644 ${fn}/*.{xml,xsl,dtd,ent} ${_pkgroot}/${fn} || true  # ignore missing files
+  done
 
-	install -dm755 ${pkgdir}/etc/xml
-	install -Dm644 COPYING ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
+  install -dm755 "$pkgdir"/etc/xml
+  install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
 }
-md5sums=('a88dbdc0cd74702656083b6e4e4241d8')
diff --git a/abs/extra/docbook-xsl/docbook-xsl.install b/abs/extra/docbook-xsl/docbook-xsl.install
index c84d929..aa386ec 100644
--- a/abs/extra/docbook-xsl/docbook-xsl.install
+++ b/abs/extra/docbook-xsl/docbook-xsl.install
@@ -5,19 +5,29 @@ post_install() {
   _NEW=`echo $1 | sed 's|\(.*\)\-.*|\1|'`
 
   xmlcatalog --noout --add "rewriteSystem" \
-    "http://docbook.sourceforge.net/release/xsl/${_NEW}" \
+    "http://cdn.docbook.org/release/xsl/${_NEW}" \
     "/usr/share/xml/docbook/xsl-stylesheets-${_NEW}" \
     etc/xml/catalog
 
   xmlcatalog --noout --add "rewriteURI" \
-    "http://docbook.sourceforge.net/release/xsl/${_NEW}" \
+    "http://cdn.docbook.org/release/xsl/${_NEW}" \
     "/usr/share/xml/docbook/xsl-stylesheets-${_NEW}" \
-    etc/xml/catalog &&
+    etc/xml/catalog
+
+  xmlcatalog --noout --add "rewriteSystem" \
+    "http://cdn.docbook.org/release/xsl/current" \
+    "/usr/share/xml/docbook/xsl-stylesheets-${_NEW}" \
+    etc/xml/catalog
+
+  xmlcatalog --noout --add "rewriteURI" \
+    "http://cdn.docbook.org/release/xsl/current" \
+    "/usr/share/xml/docbook/xsl-stylesheets-${_NEW}" \
+    etc/xml/catalog
 
   xmlcatalog --noout --add "rewriteSystem" \
     "http://docbook.sourceforge.net/release/xsl/current" \
     "/usr/share/xml/docbook/xsl-stylesheets-${_NEW}" \
-    etc/xml/catalog &&
+    etc/xml/catalog
 
   xmlcatalog --noout --add "rewriteURI" \
     "http://docbook.sourceforge.net/release/xsl/current" \
-- 
cgit v0.12

