mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 07:59:21 +08:00
Don't reject escaped forward slashes.
Closes: https://github.com/square/moshi/issues/209
This commit is contained in:
@@ -1073,6 +1073,7 @@ final class BufferedSourceJsonReader extends JsonReader {
|
||||
case '\'':
|
||||
case '"':
|
||||
case '\\':
|
||||
case '/':
|
||||
return (char) escaped;
|
||||
|
||||
default:
|
||||
|
@@ -1804,6 +1804,12 @@ public final class BufferedSourceJsonReaderTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test public void validEscapes() throws IOException {
|
||||
JsonReader reader = newReader("[\"\\\"\\\\\\/\\b\\f\\n\\r\\t\"]");
|
||||
reader.beginArray();
|
||||
assertThat(reader.nextString()).isEqualTo("\"\\/\b\f\n\r\t");
|
||||
}
|
||||
|
||||
@Test public void invalidEscape() throws IOException {
|
||||
JsonReader reader = newReader("[\"str\\ing\"]");
|
||||
reader.beginArray();
|
||||
|
Reference in New Issue
Block a user