From 4bedbd33645d22a4da2c623ccccacb2175d49b99 Mon Sep 17 00:00:00 2001
From: Marek 'marx' Grac <mgrac@redhat.com>
Date: Wed, 17 Jun 2015 19:57:05 +0200
Subject: [PATCH 10/10] fence2rng.xsl: Correctly handle quotes in description
Resolves: rhbz#1207982
---
fence/agents/lib/fence2rng.xsl | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/fence/agents/lib/fence2rng.xsl b/fence/agents/lib/fence2rng.xsl
index 432bc89..f6d465e 100644
--- a/fence/agents/lib/fence2rng.xsl
+++ b/fence/agents/lib/fence2rng.xsl
@@ -124,6 +124,12 @@
<xsl:value-of select="$NL"/>
<xsl:for-each select="parameters/parameter">
+ <xsl:variable name="escapeddesc">
+ <xsl:call-template name="escape_quot">
+ <xsl:with-param name="replace" select="shortdesc"/>
+ </xsl:call-template>
+ </xsl:variable>
+
<!-- optional (start) -->
<xsl:call-template name="tag-start">
<xsl:with-param name="name" select="'optional'"/>
@@ -136,7 +142,7 @@
<xsl:with-param name="name" select="'attribute'"/>
<xsl:with-param name="attrs" select="concat(
'name=', $Q, @name, $Q, $SP,
- 'rha:description=', $Q, normalize-space(shortdesc), $Q, $SP)"/>
+ 'rha:description=', $Q, normalize-space($escapeddesc), $Q, $SP)"/>
<xsl:with-param name="indent" select="concat($indent, $indent)"/>
</xsl:call-template>
<xsl:value-of select="$NL"/>
@@ -158,4 +164,21 @@
<xsl:value-of select="$NL"/>
</xsl:template>
+<xsl:template name="escape_quot">
+ <xsl:param name="replace"/>
+ <xsl:choose>
+ <xsl:when test="contains($replace,'"')">
+ <xsl:value-of select="substring-before($replace,'"')"/>
+ <!-- escape quot-->
+ <xsl:text>&quot;</xsl:text>
+ <xsl:call-template name="escape_quot">
+ <xsl:with-param name="replace" select="substring-after($replace,'"')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$replace"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
</xsl:stylesheet>
--
1.9.3