Don't reject escaped forward slashes.

Closes: https://github.com/square/moshi/issues/209
This commit is contained in:
jwilson
2016-10-20 21:32:58 -04:00
parent 4ff50c47ac
commit b0e11ebb1c
2 changed files with 7 additions and 0 deletions

View File

@@ -1073,6 +1073,7 @@ final class BufferedSourceJsonReader extends JsonReader {
case '\'': case '\'':
case '"': case '"':
case '\\': case '\\':
case '/':
return (char) escaped; return (char) escaped;
default: default:

View File

@@ -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 { @Test public void invalidEscape() throws IOException {
JsonReader reader = newReader("[\"str\\ing\"]"); JsonReader reader = newReader("[\"str\\ing\"]");
reader.beginArray(); reader.beginArray();