Skip to content

Commit

Permalink
bugfix for JSONValidator, fix #3293
Browse files Browse the repository at this point in the history
  • Loading branch information
ZivYan committed Jun 24, 2020
1 parent 3561431 commit c456062
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/alibaba/fastjson/JSONValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ public boolean validate() {
}

count++;
if (eof) {
return true;
}

if (supportMultiValue && !eof) {
if (supportMultiValue) {
skipWhiteSpace();
if (eof) {
break;
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/com/alibaba/json/bvt/issue_3200/Issue3293.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.alibaba.json.bvt.issue_3200;

import com.alibaba.fastjson.JSONValidator;
import junit.framework.TestCase;
import org.junit.Assert;

/**
* @Author :Nanqi
* @Date :Created in 09:59 2020/6/24
*/
public class Issue3293 extends TestCase {
public void test_for_issue() throws Exception {
JSONValidator jv = JSONValidator.from("{\"a\"}");
Assert.assertFalse(jv.validate());

jv = JSONValidator.from("113{}[]");
jv.setSupportMultiValue(false);
Assert.assertFalse(jv.validate());
Assert.assertEquals(JSONValidator.Type.Value, jv.getType());

jv = JSONValidator.from("{\"a\":\"12333\"}");
Assert.assertTrue(jv.validate());

jv = JSONValidator.from("{}");
Assert.assertTrue(jv.validate());
}
}

0 comments on commit c456062

Please sign in to comment.