code review changes from r342

Enabled escaping of /
This commit is contained in:
Inderjeet Singh 2008-12-23 18:18:14 +00:00
parent 51881c7f4a
commit e0195fcc54
2 changed files with 5 additions and 5 deletions

View File

@ -56,6 +56,7 @@ class Escaper {
tmpSet.add('>');
tmpSet.add('&');
tmpSet.add('=');
tmpSet.add('/');
tmpSet.add('\\');
JS_ESCAPE_CHARS = Collections.unmodifiableSet(tmpSet);
}
@ -77,8 +78,7 @@ class Escaper {
int codePoint = Character.codePointAt(plainText, i);
charCount = Character.charCount(codePoint);
if (!(isControlCharacter(codePoint)
|| mustEscapeCharInJsString(codePoint))) {
if (!isControlCharacter(codePoint) && !mustEscapeCharInJsString(codePoint)) {
continue;
}

View File

@ -52,12 +52,12 @@ public class DefaultTypeAdaptersTest extends TestCase {
public void testUrlSerialization() throws Exception {
String urlValue = "http://google.com/";
URL url = new URL(urlValue);
assertEquals('"' + urlValue + '"', gson.toJson(url));
assertEquals("\"http:\\/\\/google.com\\/\"", gson.toJson(url));
}
public void testUrlDeserialization() {
String urlValue = "http://google.com/";
String json = '"' + urlValue + '"';
String json = "'http:\\/\\/google.com\\/'";
URL target = gson.fromJson(json, URL.class);
assertEquals(urlValue, target.toExternalForm());
}
@ -80,7 +80,7 @@ public class DefaultTypeAdaptersTest extends TestCase {
public void testUriSerialization() throws Exception {
String uriValue = "http://google.com/";
URI uri = new URI(uriValue);
assertEquals('"' + uriValue + '"', gson.toJson(uri));
assertEquals("\"http:\\/\\/google.com\\/\"", gson.toJson(uri));
}
public void testUriDeserialization() {