cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [cxf] branch master updated: CXF-7760 - JOSE: JwsCompactConsumer parsing headers issue
Date Mon, 25 Jun 2018 17:08:42 GMT
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 40f78d5  CXF-7760 - JOSE: JwsCompactConsumer parsing headers issue
40f78d5 is described below

commit 40f78d5bdd5c38ecc535ffce9ce3aa19669ac16e
Author: Colm O hEigeartaigh <coheigea@apache.org>
AuthorDate: Mon Jun 25 18:08:14 2018 +0100

    CXF-7760 - JOSE: JwsCompactConsumer parsing headers issue
---
 .../cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java    |  9 +++++++--
 .../jaxrs/json/basic/JsonMapObjectReaderWriterTest.java    | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
b/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
index f3f176c..7be7b55 100644
--- a/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
+++ b/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
@@ -244,6 +244,11 @@ public class JsonMapObjectReaderWriter {
                 value = Double.valueOf(valueStr);
             }
         }
+
+        if (value instanceof String) {
+            // Escape an encoded forward slash
+            value = ((String) value).replace("\\/", "/");
+        }
         return value;
     }
 
@@ -263,7 +268,7 @@ public class JsonMapObjectReaderWriter {
         }
         return closingIndex;
     }
-    
+
     protected static int getNextSepCharIndex(String json, char curlyBracketChar, int from)
{
         int nextCurlyBracketIndex = -1;
         boolean inString = false;
@@ -281,7 +286,7 @@ public class JsonMapObjectReaderWriter {
         }
         return nextCurlyBracketIndex;
     }
-    
+
     public void setFormat(boolean format) {
         this.format = format;
     }
diff --git a/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
b/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
index 874beeb..9fb7456 100644
--- a/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
+++ b/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
@@ -124,4 +124,18 @@ public class JsonMapObjectReaderWriterTest extends Assert {
         assertEquals(1, xMap.size());
         assertEquals("{\\\"}", xMap.get("y"));
     }
+
+    @Test
+    public void testEscapedForwardSlashInString() throws Exception {
+        JsonMapObjectReaderWriter jsonMapObjectReaderWriter = new JsonMapObjectReaderWriter();
+        String s = "{\"kid\":\"4pZbe4shQQGzZXHbeIlbDvmHOc1\\/H6jH6oBk3nUrcZE=\",\"alg\":\"RS256\"}";
+
+        Map<String, Object> map = jsonMapObjectReaderWriter.fromJson(s);
+        assertEquals(2, map.size());
+
+        String kid = (String)map.get("kid");
+        String expectedKid = "4pZbe4shQQGzZXHbeIlbDvmHOc1/H6jH6oBk3nUrcZE=";
+        assertEquals(expectedKid, kid);
+    }
+
 }


Mime
View raw message