docbook-xsl: fix infinite recursion for e.g. samba

Closes: https://trac.macports.org/ticket/72362
This commit is contained in:
Mike L.
2025-04-28 12:53:53 +02:00
committed by Renee Otten
parent 2ff9a854bf
commit 59cdf889e6
2 changed files with 37 additions and 3 deletions
+7 -3
View File
@@ -37,7 +37,7 @@ if {${subport} eq ${name}} {
}
subport ${name}-nons {
revision 0
revision 1
description Non-namespaced version of the DocBook XSL stylesheets
distname ${subport}-${version}
checksums rmd160 63bae43e79c3b8bc3dac66711eb8c9e5ae3e4a32 \
@@ -46,7 +46,7 @@ subport ${name}-nons {
}
subport ${name}-ns {
revision 0
revision 1
description Namespaced version of the DocBook XSL stylesheets
distname ${name}-${version}
checksums rmd160 425ca8723443bcd45c23d33df26e13b930b2ce42 \
@@ -55,7 +55,7 @@ subport ${name}-ns {
}
subport ${name}-docs {
revision 0
revision 1
description Documentation for the DocBook XSL stylesheets
distname ${name}-doc-${version}
worksrcdir ${name}-${version}
@@ -76,6 +76,10 @@ use_configure no
build {}
if {${subport} in [list "${name}-nons" "${name}-ns"]} {
# Non-recursive string.subst that doesn't kill smb.conf.5 generation
# See: https://trac.macports.org/ticket/72362
patchfiles-append patch-libxsl.diff
xml.catalog ${prefix}/${instxsldir}/catalog.xml \
${prefix}/${instxsldir}/catalog.sf.xml
@@ -0,0 +1,30 @@
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
--- lib/lib.xsl.orig
+++ lib/lib.xsl
@@ -6,7 +6,10 @@
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">