mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-29 06:06:50 +08:00
bug fixed for parse iso8601 date
This commit is contained in:
@@ -3578,7 +3578,7 @@ public final class JSONLexer {
|
||||
|
||||
char dot = charAt(bp + 19);
|
||||
if (dot == '.') {
|
||||
if (rest < 23) { // 0000-00-00T00:00:00.000
|
||||
if (rest < 21) { // 0000-00-00T00:00:00.000
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -3608,7 +3608,7 @@ public final class JSONLexer {
|
||||
int millis = digits[S0];
|
||||
int millisLen = 1;
|
||||
|
||||
{
|
||||
if (rest > 21) {
|
||||
char S1 = charAt(bp + 21);
|
||||
if (S1 >= '0' && S1 <= '9') {
|
||||
millis = millis * 10 + digits[S1];
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.alibaba.json.bvt.bug;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 11/01/2017.
|
||||
*/
|
||||
public class Issue987 extends TestCase {
|
||||
public void test_for_issue() throws Exception {
|
||||
String text = "{\"date\":\"2016-11-09T09:57:20.4Z\"}";
|
||||
JSON.parseObject(text, Model.class);
|
||||
}
|
||||
|
||||
public static class Model {
|
||||
public Date date;
|
||||
}
|
||||
}
|
||||
@@ -88,8 +88,8 @@ public class JSONScannerTest_ISO8601 extends TestCase {
|
||||
Assert.assertEquals(false, new JSONLexer("2000-02-10T00:00:A0").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(true, new JSONLexer("2000-02-10T00:00:00").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(false, new JSONLexer("2000-02-10T00:00:00.").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(false, new JSONLexer("2000-02-10T00:00:00.0").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(false, new JSONLexer("2000-02-10T00:00:00.00").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(true, new JSONLexer("2000-02-10T00:00:00.0").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(true, new JSONLexer("2000-02-10T00:00:00.00").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(true, new JSONLexer("2000-02-10T00:00:00.000").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(false, new JSONLexer("2000-02-10T00:00:00.A00").scanISO8601DateIfMatch(true));
|
||||
Assert.assertEquals(false, new JSONLexer("2000-02-10T00:00:00.!00").scanISO8601DateIfMatch(true));
|
||||
|
||||
Reference in New Issue
Block a user