LANG-1396 - JsonToStringStyle does not escape string names
This commit is contained in:
parent
e7d16c2762
commit
3fadfdd69f
|
@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
<body>
|
||||
|
||||
<release version="3.8" date="2018-MM-DD" description="New features and bug fixes. Requires Java 7, supports Java 8, 9, 10.">
|
||||
<action issue="LANG-1396" type="fix" dev="sebb">JsonToStringStyle does not escape string names</action>
|
||||
<action issue="LANG-1395" type="fix" dev="sebb" due=to="Jim Gan">JsonToStringStyle does not escape double quote in a string value</action>
|
||||
<action issue="LANG-1384" type="fix" dev="erans" due-to="Ian Young">New Java version ("11") must be handled</action>
|
||||
<action issue="LANG-1364" type="fix" dev="pschumacher" due-to="Zheng Xie">ExceptionUtils#getRootCause(Throwable t) should return t if no lower level cause exists</action>
|
||||
|
|
|
@ -2619,7 +2619,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
|
||||
super.appendFieldStart(buffer, FIELD_NAME_QUOTE + fieldName
|
||||
super.appendFieldStart(buffer, FIELD_NAME_QUOTE + StringEscapeUtils.escapeJson(fieldName)
|
||||
+ FIELD_NAME_QUOTE);
|
||||
}
|
||||
|
||||
|
|
|
@ -387,6 +387,11 @@ public class JsonToStringStyleTest {
|
|||
assertEquals("{\"name\":\"Let's \\\"quote\\\" this\"}",new ToStringBuilder(base).append("name","Let's \"quote\" this").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLANG1396() {
|
||||
assertEquals("{\"Let's \\\"quote\\\" this\":\"value\"}",new ToStringBuilder(base).append("Let's \"quote\" this","value").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* An object with nested object structures used to test {@link ToStringStyle.JsonToStringStyle}.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue