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:41:07 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 3dd75e107 -> 28365ff96


[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/28365ff9
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/28365ff9
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/28365ff9

Branch: refs/heads/2.7.x-fixes
Commit: 28365ff966ee7f1866093607b9fdf923bab5d6fd
Parents: 3dd75e1
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:40:42 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/28365ff9/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/28365ff9/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