1
0
Fork 0

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
1 changed files with 2 additions and 1 deletions

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',.)"/>