mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-01 23:09:01 +00:00
Merge branch '4.0.x' into 4.1.x
Closes gh-51908
This commit is contained in:
@@ -155,7 +155,12 @@ public class BasicJsonParser extends AbstractJsonParser {
|
||||
build.setLength(0);
|
||||
}
|
||||
else if (ch == '\\') {
|
||||
tracking.set(Tracked.ESCAPE, 1);
|
||||
if (tracking.in(Tracked.OBJECT, Tracked.LIST)) {
|
||||
build.append(ch);
|
||||
}
|
||||
else {
|
||||
tracking.set(Tracked.ESCAPE, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
build.append(ch);
|
||||
|
||||
+70
-3
@@ -175,10 +175,77 @@ abstract class AbstractJsonParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void escapeDoubleQuote() {
|
||||
String input = "{\"foo\": \"\\\"bar\\\"\"}";
|
||||
void escapeBackslash() {
|
||||
String input = """
|
||||
{
|
||||
"a": "alpha\\\\"
|
||||
}
|
||||
""";
|
||||
Map<String, Object> map = this.parser.parseMap(input);
|
||||
assertThat(map).containsEntry("foo", "\"bar\"");
|
||||
assertThat(map).containsEntry("a", "alpha\\");
|
||||
}
|
||||
|
||||
@Test
|
||||
void escapeDoubleQuote() {
|
||||
String input = """
|
||||
{
|
||||
"a": "alpha\\\""
|
||||
}
|
||||
""";
|
||||
Map<String, Object> map = this.parser.parseMap(input);
|
||||
assertThat(map).containsEntry("a", "alpha\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void escapeBackslashInNestedMap() {
|
||||
String input = """
|
||||
{
|
||||
"outer": {
|
||||
"a": "alpha\\\\"
|
||||
}
|
||||
}
|
||||
""";
|
||||
Map<String, Object> map = this.parser.parseMap(input);
|
||||
assertThat(map).extractingByKey("outer", InstanceOfAssertFactories.MAP).containsEntry("a", "alpha\\");
|
||||
}
|
||||
|
||||
@Test
|
||||
void escapeDoubleQuoteInNestedMap() {
|
||||
String input = """
|
||||
{
|
||||
"outer": {
|
||||
"a": "alpha\\\""
|
||||
}
|
||||
}
|
||||
""";
|
||||
Map<String, Object> map = this.parser.parseMap(input);
|
||||
assertThat(map).extractingByKey("outer", InstanceOfAssertFactories.MAP).containsEntry("a", "alpha\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void escapeBackslashInNestedList() {
|
||||
String input = """
|
||||
{
|
||||
"list": [
|
||||
"alpha\\\\"
|
||||
]
|
||||
}
|
||||
""";
|
||||
Map<String, Object> map = this.parser.parseMap(input);
|
||||
assertThat(map).extractingByKey("list", InstanceOfAssertFactories.LIST).containsExactly("alpha\\");
|
||||
}
|
||||
|
||||
@Test
|
||||
void escapeDoubleQuoteInNestedList() {
|
||||
String input = """
|
||||
{
|
||||
"list": [
|
||||
"alpha\\\""
|
||||
]
|
||||
}
|
||||
""";
|
||||
Map<String, Object> map = this.parser.parseMap(input);
|
||||
assertThat(map).extractingByKey("list", InstanceOfAssertFactories.LIST).containsExactly("alpha\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user