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> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.2.2</version> <version>1.2.3</version>
<inceptionYear>2008</inceptionYear> <inceptionYear>2008</inceptionYear>
<name>Gson</name> <name>Gson</name>
<url>http://code.google.com/p/google-gson/</url> <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); jjCheckNAddStates(4, 7);
break; break;
case 12: case 12:
if ((0x8400000000L & l) != 0L) if ((0x808400000000L & l) != 0L)
jjCheckNAddStates(4, 7); jjCheckNAddStates(4, 7);
break; break;
case 14: case 14:
@ -396,7 +396,7 @@ private final int jjMoveNfa_0(int startState, int curPos)
jjCheckNAddStates(0, 3); jjCheckNAddStates(0, 3);
break; break;
case 23: case 23:
if ((0x8400000000L & l) != 0L) if ((0x808400000000L & l) != 0L)
jjCheckNAddStates(0, 3); jjCheckNAddStates(0, 3);
break; break;
case 25: case 25:

View File

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

View File

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

View File

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

View File

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