cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6204] Making Set-Cookie parser nearly case-insensitive, should be sufficient
Date Mon, 19 Jan 2015 16:39:28 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes ce03e76d7 -> d1362d394


[CXF-6204] Making Set-Cookie parser nearly case-insensitive, should be sufficient


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d1362d39
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d1362d39
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d1362d39

Branch: refs/heads/3.0.x-fixes
Commit: d1362d3949e8144d995bd2404dd2c4523e4a2ff1
Parents: ce03e76
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Jan 19 16:36:49 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Jan 19 16:38:55 2015 +0000

----------------------------------------------------------------------
 .../cxf/jaxrs/impl/NewCookieHeaderProvider.java | 26 +++++++++++---------
 .../jaxrs/impl/NewCookieHeaderProviderTest.java | 13 ++++++++++
 2 files changed, 28 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d1362d39/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
index 702c720..63b8819 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
@@ -51,19 +51,23 @@ public class NewCookieHeaderProvider implements HeaderDelegate<NewCookie>
{
         String[] tokens = StringUtils.split(c, ";");
         for (String token : tokens) {
             String theToken = token.trim();
-            if (theToken.startsWith(VERSION)) {
+            String theTokenUC = theToken;
+            if (!StringUtils.isEmpty(theTokenUC) && Character.isLowerCase(theTokenUC.charAt(0)))
{
+                theTokenUC = StringUtils.capitalize(theToken);
+            }
+            if (theTokenUC.startsWith(VERSION)) {
                 // should we throw an exception if it's not == 1 ?
-            } else if (theToken.startsWith(MAX_AGE)) {
-                maxAge = Integer.parseInt(theToken.substring(MAX_AGE.length() + 1));
-            } else if (theToken.startsWith(PATH)) {
-                path = theToken.substring(PATH.length() + 1);
-            } else if (theToken.startsWith(DOMAIN)) {
-                domain = theToken.substring(DOMAIN.length() + 1);
-            } else if (theToken.startsWith(COMMENT)) {
-                comment = theToken.substring(COMMENT.length() + 1);
-            } else if (theToken.startsWith(SECURE)) {
+            } else if (theTokenUC.startsWith(MAX_AGE)) {
+                maxAge = Integer.parseInt(theTokenUC.substring(MAX_AGE.length() + 1));
+            } else if (theTokenUC.startsWith(PATH)) {
+                path = theTokenUC.substring(PATH.length() + 1);
+            } else if (theTokenUC.startsWith(DOMAIN)) {
+                domain = theTokenUC.substring(DOMAIN.length() + 1);
+            } else if (theTokenUC.startsWith(COMMENT)) {
+                comment = theTokenUC.substring(COMMENT.length() + 1);
+            } else if (theTokenUC.startsWith(SECURE)) {
                 isSecure = true;
-            } else if (theToken.startsWith(EXPIRES)) {
+            } else if (theTokenUC.startsWith(EXPIRES)) {
                 // ignore
                 continue;
             } else {

http://git-wip-us.apache.org/repos/asf/cxf/blob/d1362d39/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
index 0f08348..9b2b51e 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
@@ -59,6 +59,19 @@ public class NewCookieHeaderProviderTest extends Assert {
                    && 10 == c.getMaxAge());
     }
     
+    @Test
+    public void testFromComplexStringLowerCase() {
+        NewCookie c = NewCookie.valueOf(
+                      "foo=bar;comment=comment;path=path;max-Age=10;domain=domain;secure;version=1");
+        assertTrue("bar".equals(c.getValue())
+                   && "foo".equals(c.getName())
+                   && 1 == c.getVersion()
+                   && "path".equals(c.getPath())
+                   && "domain".equals(c.getDomain())
+                   && "comment".equals(c.getComment())
+                   && 10 == c.getMaxAge());
+    }
+    
     
     @Test
     public void testFromStringWithSpaces() {


Mime
View raw message