Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/pages/test_qo_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ def test_chart_arrays_follow_timestamp_instants
end
end

def test_non_numeric_metric_values_are_not_emitted_as_javascript
xml = xslt(
"<r><xsl:call-template name='qo-section'>" \
"<xsl:with-param name='what' select=\"'quality-of-service'\"/>" \
"<xsl:with-param name='title' select=\"'QoS'\"/>" \
'</xsl:call-template></r>',
'<fb><f><when>2024-07-03T22:22:22Z</when><what>quality-of-service</what>' \
'<n_composite>0]}]});alert(document.domain);}); //</n_composite></f></fb>',
'today' => '2024-09-26T04:04:04Z'
)
script = xml.xpath('//script').map(&:content).join
assert_match(/data:\[null\]/, script)
refute_includes(script, 'alert(document.domain)')
end

def test_keeps_the_before_block_out_of_a_paragraph
xml = xslt(
"<r><xsl:call-template name='qo-section'>" \
Expand Down
4 changes: 2 additions & 2 deletions xsl/qo-section.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@
</xsl:if>
<xsl:variable name="cell" select="*[name()=$n][1]/text()"/>
<xsl:choose>
<xsl:when test="$cell = ''">
<xsl:when test="not(normalize-space($cell) castable as xs:decimal)">
<xsl:text>null</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$cell"/>
<xsl:value-of select="xs:decimal(normalize-space($cell))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
Expand Down
Loading