code review changes from r342
Enabled escaping of /
This commit is contained in:
parent
51881c7f4a
commit
e0195fcc54
|
@ -56,6 +56,7 @@ class Escaper {
|
||||||
tmpSet.add('>');
|
tmpSet.add('>');
|
||||||
tmpSet.add('&');
|
tmpSet.add('&');
|
||||||
tmpSet.add('=');
|
tmpSet.add('=');
|
||||||
|
tmpSet.add('/');
|
||||||
tmpSet.add('\\');
|
tmpSet.add('\\');
|
||||||
JS_ESCAPE_CHARS = Collections.unmodifiableSet(tmpSet);
|
JS_ESCAPE_CHARS = Collections.unmodifiableSet(tmpSet);
|
||||||
}
|
}
|
||||||
|
@ -77,8 +78,7 @@ class Escaper {
|
||||||
int codePoint = Character.codePointAt(plainText, i);
|
int codePoint = Character.codePointAt(plainText, i);
|
||||||
charCount = Character.charCount(codePoint);
|
charCount = Character.charCount(codePoint);
|
||||||
|
|
||||||
if (!(isControlCharacter(codePoint)
|
if (!isControlCharacter(codePoint) && !mustEscapeCharInJsString(codePoint)) {
|
||||||
|| mustEscapeCharInJsString(codePoint))) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,12 +52,12 @@ public class DefaultTypeAdaptersTest extends TestCase {
|
||||||
public void testUrlSerialization() throws Exception {
|
public void testUrlSerialization() throws Exception {
|
||||||
String urlValue = "http://google.com/";
|
String urlValue = "http://google.com/";
|
||||||
URL url = new URL(urlValue);
|
URL url = new URL(urlValue);
|
||||||
assertEquals('"' + urlValue + '"', gson.toJson(url));
|
assertEquals("\"http:\\/\\/google.com\\/\"", gson.toJson(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUrlDeserialization() {
|
public void testUrlDeserialization() {
|
||||||
String urlValue = "http://google.com/";
|
String urlValue = "http://google.com/";
|
||||||
String json = '"' + urlValue + '"';
|
String json = "'http:\\/\\/google.com\\/'";
|
||||||
URL target = gson.fromJson(json, URL.class);
|
URL target = gson.fromJson(json, URL.class);
|
||||||
assertEquals(urlValue, target.toExternalForm());
|
assertEquals(urlValue, target.toExternalForm());
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class DefaultTypeAdaptersTest extends TestCase {
|
||||||
public void testUriSerialization() throws Exception {
|
public void testUriSerialization() throws Exception {
|
||||||
String uriValue = "http://google.com/";
|
String uriValue = "http://google.com/";
|
||||||
URI uri = new URI(uriValue);
|
URI uri = new URI(uriValue);
|
||||||
assertEquals('"' + uriValue + '"', gson.toJson(uri));
|
assertEquals("\"http:\\/\\/google.com\\/\"", gson.toJson(uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUriDeserialization() {
|
public void testUriDeserialization() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user