Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix for JSONValidator, fix #3293 #3296

Merged
merged 1 commit into from
Jun 25, 2020
Merged
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
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());
}
}