Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -1870,11 +1870,24 @@ protected JsonToken _handleOddValue(int i) throws IOException
_reportError("Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
break;
case 'I':
_matchToken("Infinity", 1);
if (_inputPtr >= _inputEnd) {
if (!_loadMore()) {
_reportInvalidEOFInValue();
}
}

String match = null;
if (_inputBuffer[_inputPtr] == 'n') {
_matchToken("Infinity", 1);
match = "Infinity";
} else {
_matchToken("INF", 1);
match = "INF";
}
if (isEnabled(Feature.ALLOW_NON_NUMERIC_NUMBERS)) {
return resetAsNaN("Infinity", Double.POSITIVE_INFINITY);
return resetAsNaN(match, Double.POSITIVE_INFINITY);
}
_reportError("Non-standard token 'Infinity': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
_reportError("Non-standard token '"+match+"': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
break;
case '+': // note: '-' is taken as number
if (_inputPtr >= _inputEnd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2025,11 +2025,19 @@ protected JsonToken _handleUnexpectedValue(int c)
_reportError("Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
break;
case 'I':
_matchToken("Infinity", 1);
String match = null;
int nextChar = _inputData.readUnsignedByte();
if (nextChar == 'n') {
_matchToken("Infinity", 2);
match = "Infinity";
} else {
_matchToken("INF", 2);
match = "INF";
}
if (isEnabled(Feature.ALLOW_NON_NUMERIC_NUMBERS)) {
return resetAsNaN("Infinity", Double.POSITIVE_INFINITY);
return resetAsNaN(match, Double.POSITIVE_INFINITY);
}
_reportError("Non-standard token 'Infinity': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
_reportError("Non-standard token '"+match+"': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
break;
case '+': // note: '-' is taken as number
return _handleInvalidNumberStart(_inputData.readUnsignedByte(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2664,11 +2664,24 @@ protected JsonToken _handleUnexpectedValue(int c)
_reportError("Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
break;
case 'I':
_matchToken("Infinity", 1);
if (_inputPtr >= _inputEnd) {
if (!_loadMore()) {
_reportInvalidEOFInValue();
}
}

String match = null;
if (_inputBuffer[_inputPtr] == 'n') {
_matchToken("Infinity", 1);
match = "Infinity";
} else {
_matchToken("INF", 1);
match = "INF";
}
if (isEnabled(Feature.ALLOW_NON_NUMERIC_NUMBERS)) {
return resetAsNaN("Infinity", Double.POSITIVE_INFINITY);
return resetAsNaN(match, Double.POSITIVE_INFINITY);
}
_reportError("Non-standard token 'Infinity': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
_reportError("Non-standard token '"+match+"': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow");
break;
case '+': // note: '-' is taken as number
if (_inputPtr >= _inputEnd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private void _testAllowNaN(int mode) throws Exception

private void _testAllowInf(int mode) throws Exception
{
final String JSON = "[ -INF, +INF, +Infinity, Infinity, -Infinity ]";
final String JSON = "[ -INF, +INF, INF, +Infinity, Infinity, -Infinity ]";
JsonFactory f = new JsonFactory();
assertFalse(f.isEnabled(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS));

Expand Down Expand Up @@ -499,6 +499,12 @@ private void _testAllowInf(int mode) throws Exception
assertTrue(Double.isInfinite(d));
assertTrue(d == Double.POSITIVE_INFINITY);

assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
d = p.getDoubleValue();
assertEquals("INF", p.getText());
assertTrue(Double.isInfinite(d));
assertTrue(d == Double.POSITIVE_INFINITY);

assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
d = p.getDoubleValue();
assertEquals("+Infinity", p.getText());
Expand Down Expand Up @@ -530,6 +536,7 @@ private void _testAllowInf(int mode) throws Exception
assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertToken(JsonToken.END_ARRAY, p.nextToken());

p.close();
Expand Down