diff --git a/pom.xml b/pom.xml index daa515fefb..4f7e0b20b3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.alibaba fastjson - 1.2.69 + 1.2.70_preview_04 jar fastjson @@ -14,8 +14,9 @@ 2012 - false - false + 4.12 + true + true UTF-8 1.6 @@ -25,14 +26,6 @@ scm:git:https://git@github.com/alibaba/fastjson.git - - - local-file - file://${basedir}/lib/ - default - - - Alibaba Group https://github.com/alibaba @@ -132,6 +125,7 @@ org.apache.maven.plugins maven-source-plugin + 3.2.0 attach-sources @@ -156,7 +150,9 @@ + org.apache.maven.plugins maven-javadoc-plugin + 3.2.0 attach-javadoc @@ -178,7 +174,9 @@ + org.apache.maven.plugins maven-gpg-plugin + 1.6 ${gpg.skip} @@ -320,5 +318,355 @@ 0.36 provided + + + com.google.protobuf + protobuf-java + 3.11.0 + provided + + + com.google.protobuf + protobuf-java-util + 3.11.0 + provided + + + + org.jacoco + jacoco-maven-plugin + 0.7.6.201602180812 + provided + + + + org.eclipse.jetty + jetty-server + 9.4.17.v20190418 + test + true + + + org.eclipse.jetty + jetty-webapp + 9.4.17.v20190418 + test + true + + + + junit + junit + ${junit.version} + test + + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + test + + + com.fasterxml.jackson.module + jackson-module-afterburner + 2.10.0 + test + + + com.fasterxml.jackson.module + jackson-module-kotlin + 2.9.10 + test + + + + cglib + cglib-nodep + 2.2.2 + test + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + 2.9.10 + test + + + com.googlecode.json-simple + json-simple + 1.1.1 + test + + + + commons-io + commons-io + 1.4 + test + + + + net.sf.json-lib + json-lib + 2.4 + jdk15 + test + + + + com.google.code.gson + gson + 2.6.2 + test + + + net.minidev + json-smart + 2.2.1 + test + + + + org.clojure + clojure + 1.5.1 + test + + + org.codehaus.groovy + groovy + 2.1.5 + test + + + + org.springframework + spring-test + 4.3.7.RELEASE + test + + + org.javassist + javassist + 3.18.0-GA + test + + + + org.apache.cxf + cxf-rt-rs-client + 3.1.2 + test + + + + org.springframework.data + spring-data-commons + 2.1.2.RELEASE + test + + + + org.glassfish.jersey.containers + jersey-container-servlet + 2.23.2 + test + + + org.glassfish.jersey.core + jersey-client + 2.23.2 + test + + + org.glassfish.jersey.test-framework.providers + jersey-test-framework-provider-jdk-http + 2.23.2 + test + + + org.glassfish.jersey.media + jersey-media-json-jackson + 2.23.2 + test + + + com.jsoniter + jsoniter + 0.9.8 + test + + + + org.apache.commons + commons-lang3 + 3.5 + test + + + + org.hibernate + hibernate-core + 5.2.10.Final + test + + + + com.jayway.jsonpath + json-path + 2.3.0 + test + + + + org.jetbrains.kotlin + kotlin-stdlib + 1.1.51 + test + + + + org.jetbrains.kotlin + kotlin-reflect + 1.1.51 + test + + + + org.springframework.security + spring-security-web + 4.2.3.RELEASE + test + + + + org.apache.commons + commons-collections4 + 4.1 + test + + + + org.mockito + mockito-all + 1.10.19 + test + + + org.powermock + powermock-module-junit4 + 1.6.6 + test + + + com.diffblue + deeptestutils + 1.1.0 + test + + + + org.projectlombok + lombok + 1.18.4 + test + + + + org.openjdk.jmh + jmh-core + 1.21 + test + + + org.openjdk.jmh + jmh-generator-annprocess + 1.21 + test + + + + + org.springframework.security.oauth + spring-security-oauth2 + 2.3.5.RELEASE + + + commons-codec + commons-codec + + + jackson + jackson-mapper-asl + + + jackson + jackson-core-asl + + + test + + + + org.gitlab4j + gitlab4j-api + 4.8.42 + test + + + + org.json + json + 20180130 + test + + + + com.chinamobile.cmos + sms-core + 2.1.9 + test + + + + + travis + + + env.TRAVIS + true + + + + + + + + + org.jacoco + jacoco-maven-plugin + 0.7.6.201602180812 + + + + prepare-agent + + + + report + test + + report + + + + + + + + + diff --git a/src/main/java/com/alibaba/fastjson/serializer/SerialContext.java b/src/main/java/com/alibaba/fastjson/serializer/SerialContext.java index c6263a9239..a65a9fe88a 100644 --- a/src/main/java/com/alibaba/fastjson/serializer/SerialContext.java +++ b/src/main/java/com/alibaba/fastjson/serializer/SerialContext.java @@ -59,6 +59,10 @@ protected void toString(StringBuilder buf) { } else if ((ch >= '0' && ch <='9') || (ch >= 'A' && ch <='Z') || (ch >= 'a' && ch <='z') || ch > 128) { buf.append(ch); continue; + } else if(ch == '\"'){ + buf.append('\\'); + buf.append('\\'); + buf.append('\\'); } else { buf.append('\\'); buf.append('\\'); diff --git a/src/test/java/com/alibaba/fastjson/serializer/issue3084/TestRefWithQuote.java b/src/test/java/com/alibaba/fastjson/serializer/issue3084/TestRefWithQuote.java new file mode 100644 index 0000000000..43947eb0ad --- /dev/null +++ b/src/test/java/com/alibaba/fastjson/serializer/issue3084/TestRefWithQuote.java @@ -0,0 +1,45 @@ +package com.alibaba.fastjson.serializer.issue3084; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.*; + +public class TestRefWithQuote { + + public static class X { + private String x; + + public X(String x) { + this.x = x; + } + + public String getX() { + return x; + } + + public void setX(String x) { + this.x = x; + } + } + + @Test + public void testIssue3084() { + Map origin = new HashMap<>(); + TestRefWithQuote.X x = new TestRefWithQuote.X("x"); + origin.put("aaaa\"", x); + origin.put("bbbb\"", x); + + try { + String json = JSON.toJSONString(origin, true); + JSONObject root = JSON.parseObject(json); + assertSame(root.get("bbbb\\"), root.get("aaaa\\")); + } catch (Exception e) { + fail("should not fail !!!"); + } + } +} diff --git a/src/test/java/com/alibaba/json/bvt/issue_3200/Issue3206.java b/src/test/java/com/alibaba/json/bvt/issue_3200/Issue3206.java new file mode 100644 index 0000000000..0e863b1691 --- /dev/null +++ b/src/test/java/com/alibaba/json/bvt/issue_3200/Issue3206.java @@ -0,0 +1,29 @@ +package com.alibaba.json.bvt.issue_3200; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.annotation.JSONField; +import com.alibaba.fastjson.serializer.NameFilter; +import junit.framework.TestCase; + +public class Issue3206 extends TestCase { + public void test_for_issue() throws Exception { + VO vo = new VO(); + vo.date = new java.util.Date(1590819204293L); + + + assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}"); + + String str = JSON.toJSONString(vo, new NameFilter() { + @Override + public String process(Object object, String name, Object value) { + return name; + } + }); + assertEquals(str, "{\"date\":\"2020-05-30\"}"); + } + + public static class VO { + @JSONField(format="yyyy-MM-dd") + public java.util.Date date; + } +}