From c3a9b5ecda36161a09dea6f161f8f5b7756f0c8c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 22 Apr 2020 19:26:45 -0700 Subject: [PATCH] more work for #611 --- .../core/json/ReaderBasedJsonParser.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java b/src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java index 41f2edb67d..c0e3fd0ab0 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java +++ b/src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java @@ -757,6 +757,9 @@ public final JsonToken nextToken() throws IOException */ t = _parseNegNumber(); break; + case '.': // [core#61]] + t = _parseFloatThatStartsWithPeriod(); + break; case '0': case '1': case '2': @@ -950,6 +953,9 @@ public String nextFieldName() throws IOException case '-': t = _parseNegNumber(); break; + case '.': // [core#61]] + t = _parseFloatThatStartsWithPeriod(); + break; case '0': case '1': case '2': @@ -1019,6 +1025,9 @@ private final void _isNextTokenNameYes(int i) throws IOException case '-': _nextToken = _parseNegNumber(); return; + case '.': // [core#61]] + _nextToken = _parseFloatThatStartsWithPeriod(); + return; case '0': case '1': case '2': @@ -1054,6 +1063,9 @@ protected boolean _isNextTokenNameMaybe(int i, String nameToMatch) throws IOExce case '-': t = _parseNegNumber(); break; + case '.': // [core#61]] + t = _parseFloatThatStartsWithPeriod(); + break; case '0': case '1': case '2': @@ -1120,6 +1132,8 @@ private final JsonToken _nextTokenNotInObject(int i) throws IOException * it is not allowed per se, it may be erroneously used, * and could be indicated by a more specific error message. */ + case '.': // [core#61]] + return (_currToken = _parseFloatThatStartsWithPeriod()); case '0': case '1': case '2': @@ -1258,6 +1272,16 @@ public final Boolean nextBooleanValue() throws IOException /********************************************************** */ + // @since 2.11, [core#611] + protected final JsonToken _parseFloatThatStartsWithPeriod() throws IOException + { + // [core#611]: allow optionally leading decimal point + if (!isEnabled(JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS.mappedFeature())) { + return _handleOddValue('.'); + } + return _parseFloat(INT_PERIOD, _inputPtr-1, _inputPtr, false, 0); + } + /** * Initial parsing method for number values. It needs to be able * to parse enough input to be able to determine whether the