aboutsummaryrefslogtreecommitdiff
path: root/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java')
-rw-r--r--java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
index 6ef08508..d9bbe587 100644
--- a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
+++ b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
@@ -70,7 +70,6 @@ import java.io.StringReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
@@ -1188,10 +1187,14 @@ public class JsonFormatTest extends TestCase {
assertRoundTripEquals(message);
}
- public void testDefaultGsonDoesNotHtmlEscape() throws Exception {
- TestAllTypes message = TestAllTypes.newBuilder().setOptionalString("=").build();
- assertEquals(
- "{\n" + " \"optionalString\": \"=\"" + "\n}", JsonFormat.printer().print(message));
+ // Regression test for b/73832901. Make sure html tags are escaped.
+ public void testHtmlEscape() throws Exception {
+ TestAllTypes message = TestAllTypes.newBuilder().setOptionalString("</script>").build();
+ assertEquals("{\n \"optionalString\": \"\\u003c/script\\u003e\"\n}", toJsonString(message));
+
+ TestAllTypes.Builder builder = TestAllTypes.newBuilder();
+ JsonFormat.parser().merge(toJsonString(message), builder);
+ assertEquals(message.getOptionalString(), builder.getOptionalString());
}
public void testIncludingDefaultValueFields() throws Exception {