Skip to content

Commit 18c67e8

Browse files
committed
Fixed replacement issue
1 parent f6a376a commit 18c67e8

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

scripts/handleIssues.xslt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,48 @@
3131
<xsl:param name="code"/>
3232
<xsl:param name="details"/>
3333
<xsl:param name="location"/>
34+
<xsl:variable name="escapedDetails1">
35+
<xsl:call-template name="replace">
36+
<xsl:with-param name="string" select="$details"/>
37+
<xsl:with-param name="search" select="'\'"/>
38+
<xsl:with-param name="new" select="'\\'"/>
39+
</xsl:call-template>
40+
</xsl:variable>
41+
<xsl:variable name="escapedDetails2">
42+
<xsl:call-template name="replace">
43+
<xsl:with-param name="string" select="$escapedDetails1"/>
44+
<xsl:with-param name="search" select="'&quot;'"/>
45+
<xsl:with-param name="new" select="'\&quot;'"/>
46+
</xsl:call-template>
47+
</xsl:variable>
3448
<xsl:text>&#xa;{"severity":"</xsl:text>
3549
<xsl:value-of select="$severity"/>
3650
<xsl:text>","code":"</xsl:text>
3751
<xsl:value-of select="$code"/>
3852
<xsl:text>","details":{"text":"</xsl:text>
39-
<xsl:value-of select="translate(translate($details, '\', '\\'), '&quot;', '\&quot;')"/>
53+
<xsl:value-of select="$escapedDetails2"/>
4054
<xsl:text>"},"location":["</xsl:text>
4155
<xsl:value-of select="$location"/>
4256
<xsl:text>"]}&#xa;,</xsl:text>
4357
</xsl:template>
58+
<xsl:template name="replace">
59+
<xsl:param name="string"/>
60+
<xsl:param name="search"/>
61+
<xsl:param name="new"/>
62+
<xsl:choose>
63+
<xsl:when test="contains($string, $search)">
64+
<xsl:variable name="remainder">
65+
<xsl:call-template name="replace">
66+
<xsl:with-param name="string" select="substring-after($string, $search)"/>
67+
<xsl:with-param name="search" select="$search"/>
68+
<xsl:with-param name="new" select="$new"/>
69+
</xsl:call-template>
70+
</xsl:variable>
71+
<xsl:value-of select="concat(substring-before($string, $search), $new, $remainder)"/>
72+
</xsl:when>
73+
<xsl:otherwise>
74+
<xsl:value-of select="$string"/>
75+
</xsl:otherwise>
76+
</xsl:choose>
77+
</xsl:template>
4478
</xsl:stylesheet>

0 commit comments

Comments
 (0)