Browse Source

Try to reduce the risk of StackOverflow/OOM in junitereport

Submitted by: Ryan Bennitt
Bugzilla: https://issues.apache.org/bugzilla/show_bug.cgi?id=57341
master
Stefan Bodewig 10 years ago
parent
commit
f7f5327d28
5 changed files with 46 additions and 2 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +5
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +18
    -1
      src/etc/junit-frames.xsl
  5. +18
    -1
      src/etc/junit-noframes.xsl

+ 1
- 0
CONTRIBUTORS View File

@@ -330,6 +330,7 @@ Roger Vaughn
Roman Ivashin
Ronen Mashal
Russell Gold
Ryan Bennitt
Sam Ruby
Sandra Metz
Scott Carlson


+ 5
- 0
WHATSNEW View File

@@ -55,6 +55,11 @@ Fixed bugs:
* complete-ant-cmd.pl now also knows about the -file option.
Bugzilla Report 57371

* the br-replace template inside the XSLT stylesheets used by
<junitreport> could cause stack overflows or out-of-memory errors
when applied to big outputs.
Bugzilla Report 57341

Other changes:
--------------



+ 4
- 0
contributors.xml View File

@@ -1333,6 +1333,10 @@
<first>Russell</first>
<last>Gold</last>
</name>
<name>
<first>Ryan</first>
<last>Bennitt</last>
</name>
<name>
<first>Sam</first>
<last>Ruby</last>


+ 18
- 1
src/etc/junit-frames.xsl View File

@@ -929,7 +929,24 @@ h6 {
-->
<xsl:template name="br-replace">
<xsl:param name="word"/>
<xsl:param name="splitlimit">32</xsl:param>
<xsl:variable name="secondhalflen" select="(string-length($word)+(string-length($word) mod 2)) div 2"/>
<xsl:variable name="secondhalfword" select="substring($word, $secondhalflen)"/>
<!-- When word is very big, a recursive replace is very heap/stack expensive, so subdivide on line break after middle of string -->
<xsl:choose>
<xsl:when test="(string-length($word) > $splitlimit) and (contains($secondhalfword, '&#xa;'))">
<xsl:variable name="secondhalfend" select="substring-after($secondhalfword, '&#xa;')"/>
<xsl:variable name="firsthalflen" select="string-length($word) - $secondhalflen"/>
<xsl:variable name="firsthalfword" select="substring($word, 1, $firsthalflen)"/>
<xsl:variable name="firsthalfend" select="substring-before($secondhalfword, '&#xa;')"/>
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="concat($firsthalfword,$firsthalfend)"/>
</xsl:call-template>
<br/>
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="$secondhalfend"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($word, '&#xa;')">
<xsl:value-of select="substring-before($word, '&#xa;')"/>
<br/>
@@ -938,7 +955,7 @@ h6 {
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$word"/>
<xsl:value-of select="$word"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


+ 18
- 1
src/etc/junit-noframes.xsl View File

@@ -469,7 +469,24 @@
-->
<xsl:template name="br-replace">
<xsl:param name="word"/>
<xsl:param name="splitlimit">32</xsl:param>
<xsl:variable name="secondhalflen" select="(string-length($word)+(string-length($word) mod 2)) div 2"/>
<xsl:variable name="secondhalfword" select="substring($word, $secondhalflen)"/>
<!-- When word is very big, a recursive replace is very heap/stack expensive, so subdivide on line break after middle of string -->
<xsl:choose>
<xsl:when test="(string-length($word) > $splitlimit) and (contains($secondhalfword, '&#xa;'))">
<xsl:variable name="secondhalfend" select="substring-after($secondhalfword, '&#xa;')"/>
<xsl:variable name="firsthalflen" select="string-length($word) - $secondhalflen"/>
<xsl:variable name="firsthalfword" select="substring($word, 1, $firsthalflen)"/>
<xsl:variable name="firsthalfend" select="substring-before($secondhalfword, '&#xa;')"/>
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="concat($firsthalfword,$firsthalfend)"/>
</xsl:call-template>
<br/>
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="$secondhalfend"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($word, '&#xa;')">
<xsl:value-of select="substring-before($word, '&#xa;')"/>
<br/>
@@ -478,7 +495,7 @@
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$word"/>
<xsl:value-of select="$word"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


Loading…
Cancel
Save