Issue #2391 - JSON Solidus is optional for escaping

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2018-04-05 09:13:37 -05:00
parent 5cab0ccd5f
commit 46c5824e7a
2 changed files with 4 additions and 2 deletions

View File

@ -273,7 +273,9 @@ public class JSON
if ((c >= 0x20) && (c <= 0x7E))
{
// Special cases for quotation-mark, reverse-solidus, and solidus
if ((c == '"') || (c == '\\') || (c == '/'))
if ((c == '"') || (c == '\\')
/* solidus is optional - per Carsten Bormann (IETF)
|| (c == '/') */)
{
buffer.append('\\').append(c);
}

View File

@ -363,7 +363,7 @@ public class JSONTest
json.append(buf,map);
String js=buf.toString();
assertTrue(js.indexOf("\"date\":\"01\\/01\\/1970 00:00:00 GMT\"")>=0);
assertTrue(js.indexOf("\"date\":\"01/01/1970 00:00:00 GMT\"")>=0);
assertTrue(js.indexOf("org.eclipse.jetty.util.ajax.JSONTest$Woggle")>=0);
assertTrue(js.indexOf("org.eclipse.jetty.util.ajax.JSONTest$Gizmo")<0);
assertTrue(js.indexOf("\"tested\":true")>=0);