Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3182 from CS304-mahoushoujyo/alibaba#3084
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao authored May 31, 2020
2 parents bc35d72 + c7b7f8d commit e62525f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<gpg.skip>true</gpg.skip>
<javadoc.skip>true</javadoc.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.6</jdk.version>
<jdk.version>1.7</jdk.version>
</properties>

<scm>
Expand Down Expand Up @@ -133,6 +133,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -157,7 +158,9 @@
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadoc</id>
Expand All @@ -179,7 +182,9 @@
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<configuration>
<skip>${gpg.skip}</skip>
</configuration>
Expand Down Expand Up @@ -322,6 +327,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('\\');
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, TestRefWithQuote.X> 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 !!!");
}
}
}

0 comments on commit e62525f

Please sign in to comment.