Fixed issue 66 to allow escaped slash ( \/) as a valid Json escaped character.

Changed Gson version to 1.2.3.
This commit is contained in:
Inderjeet Singh 2008-10-29 23:31:13 +00:00
parent 7aa1d0f6aa
commit c98d7bc340
8 changed files with 1498 additions and 1488 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<packaging>jar</packaging>
<version>1.2.2</version>
<version>1.2.3</version>
<inceptionYear>2008</inceptionYear>
<name>Gson</name>
<url>http://code.google.com/p/google-gson/</url>

View File

@ -364,7 +364,7 @@ private final int jjMoveNfa_0(int startState, int curPos)
jjCheckNAddStates(4, 7);
break;
case 12:
if ((0x8400000000L & l) != 0L)
if ((0x808400000000L & l) != 0L)
jjCheckNAddStates(4, 7);
break;
case 14:
@ -396,7 +396,7 @@ private final int jjMoveNfa_0(int startState, int curPos)
jjCheckNAddStates(0, 3);
break;
case 23:
if ((0x8400000000L & l) != 0L)
if ((0x808400000000L & l) != 0L)
jjCheckNAddStates(0, 3);
break;
case 25:

View File

@ -63,6 +63,9 @@ final class StringUnmarshaller {
case '\\':
ch = '\\';
break;
case '/':
ch = '/';
break;
default:
throw new IllegalStateException("Unexpected character: " + c + " in " + str);
}

View File

@ -30,7 +30,7 @@ TOKEN : {
| <DIGITS : (["0"-"9"])+>
| <#HEX_CHAR : ["a"-"f","A"-"F","0"-"9"]>
| <UNICODE_CHAR : "\\u" <HEX_CHAR><HEX_CHAR><HEX_CHAR><HEX_CHAR> >
| <#ESCAPE_CHAR: "\\" ["n","t","b","r","f","\\","'","\""] >
| <#ESCAPE_CHAR: "\\" ["n","t","b","r","f","\\","'","\"", "/"] >
| <SINGLE_QUOTE_LITERAL: "\'" ( (~["\'","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\'" >
| <DOUBLE_QUOTE_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\"" >
| <QUOTE : "\""> : STRING_STATE

View File

@ -122,9 +122,9 @@ public class ConcurrencyTest extends TestCase {
}
private static class MyObject {
private String a;
private String b;
private int i;
String a;
String b;
int i;
MyObject() {
this("hello", "world", 42);

View File

@ -102,4 +102,11 @@ public class StringTest extends TestCase {
String actual = gson.fromJson("[\"" + value + "\"]", String.class);
assertEquals(value, actual);
}
public void testStringWithEscapedSlashDeserialization() {
String value = "/";
String json = "'\\/'";
String actual = gson.fromJson(json, String.class);
assertEquals(value, actual);
}
}