Skip to content

Commit 9573214

Browse files
committed
Merge branch '1.5.x' into 2.0.x
2 parents bff93a6 + ccbbe0f commit 9573214

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,16 @@ private List<String> tokenize(String json) {
113113
int inObject = 0;
114114
int inList = 0;
115115
boolean inValue = false;
116+
boolean inEscape = false;
116117
StringBuilder build = new StringBuilder();
117118
while (index < json.length()) {
118119
char current = json.charAt(index);
120+
if (inEscape) {
121+
build.append(current);
122+
index++;
123+
inEscape = false;
124+
continue;
125+
}
119126
if (current == '{') {
120127
inObject++;
121128
}
@@ -135,6 +142,9 @@ private List<String> tokenize(String json) {
135142
list.add(build.toString());
136143
build.setLength(0);
137144
}
145+
else if (current == '\\') {
146+
inEscape = true;
147+
}
138148
else {
139149
build.append(current);
140150
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/AbstractJsonParserTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,11 @@ public void listWithLeadingWhitespaceMapThrowsARuntimeException() {
170170
this.parser.parseList("\n\t{}");
171171
}
172172

173+
@Test
174+
public void escapeQuote() {
175+
String input = "{\"foo\": \"\\\"bar\\\"\"}";
176+
Map<String, Object> map = this.parser.parseMap(input);
177+
assertThat(map.get("foo")).isEqualTo("\"bar\"");
178+
}
179+
173180
}

0 commit comments

Comments
 (0)