1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Fix issue with only "-" and whitespace in element

Fixes: #2198

If there is a single "-" or it is only accompanied by whitespace, then
it wouldn't get escaped as it was detected as as a number. This would
produce invalid JSON.
This makes the numbers part ignore such and thus ensures it gets escaped
as text.

There might be other corner cases related to number parsing, this should be investigated.
This commit is contained in:
Thomas B. Ruecker 2015-05-16 17:30:34 +00:00
parent 0b1ac3e9d5
commit 56bbc0d12c

View File

@ -126,7 +126,8 @@
<!-- number (no support for javascript mantissa) -->
<xsl:template match="text()[not(string(number())='NaN' or
(starts-with(.,'0' ) and . != '0' and not(starts-with(.,'0.' ))) or
(starts-with(.,'-0' ) and . != '-0' and not(starts-with(.,'-0.' ))))]">
(starts-with(.,'-0' ) and . != '-0' and not(starts-with(.,'-0.' )))) and
not(substring(normalize-space(.), string-length(normalize-space(.))) = '-')]">
<xsl:choose>
<xsl:when test="starts-with(.,'.')">
<xsl:value-of select="concat('0',.)"/>