THRIFT-2297: TJsonProtocol implementation for Delphi does not allow for both possible slash (solidus) encodings, including a test case

Patch: Jens Geyer
diff --git a/lib/delphi/src/Thrift.Protocol.JSON.pas b/lib/delphi/src/Thrift.Protocol.JSON.pas
index 2cc4bbd..cce6c3c 100644
--- a/lib/delphi/src/Thrift.Protocol.JSON.pas
+++ b/lib/delphi/src/Thrift.Protocol.JSON.pas
@@ -264,8 +264,8 @@
                      0,0,0,0, 0,0,0,0, 0,0,0,0,  0,0,0,0,
                      1,1,Byte('"'),1,  1,1,1,1, 1,1,1,1, 1,1,1,1);
 
-  ESCAPE_CHARS     = '"\btnfr';
-  ESCAPE_CHAR_VALS = '"\'#8#9#10#12#13;
+  ESCAPE_CHARS     = '"\/btnfr';
+  ESCAPE_CHAR_VALS = '"\/'#8#9#10#12#13;
 
   DEF_STRING_SIZE = 16;
 
diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas
index e63bd4c..0f09489 100644
--- a/lib/delphi/test/TestClient.pas
+++ b/lib/delphi/test/TestClient.pas
@@ -898,6 +898,9 @@
   TEST_DOUBLE  = -1.234e-56;
   DELTA_DOUBLE = TEST_DOUBLE * 1e-14;
   TEST_STRING  = 'abc-'#$00E4#$00f6#$00fc; // german umlauts (en-us: "funny chars")
+  // test both possible solidus encodings
+  SOLIDUS_JSON_DATA = '"one/two\/three"';
+  SOLIDUS_EXCPECTED = 'one/two/three';
 begin
   stm  := TStringStream.Create;
   try
@@ -962,6 +965,17 @@
 
     Expect( stm.Position = stm.Size, 'Stream position after read');
 
+    // Solidus can be encoded in two ways. Make sure we can read both
+    stm.Position := 0;
+    stm.Size     := 0;
+    stm.WriteString(SOLIDUS_JSON_DATA);
+    stm.Position := 0;
+    prot := TJSONProtocolImpl.Create(
+              TStreamTransportImpl.Create(
+                TThriftStreamAdapterDelphi.Create( stm, FALSE), nil));
+    Expect( prot.ReadString = SOLIDUS_EXCPECTED, 'Solidus encoding');
+
+
   finally
     stm.Free;
     prot := nil;  //-> Release