commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r399735 - /jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java
Date Thu, 04 May 2006 15:31:14 GMT
Author: olegk
Date: Thu May  4 08:31:12 2006
New Revision: 399735

URL: http://svn.apache.org/viewcvs?rev=399735&view=rev
Log:
Fixed inconsistencies in usage of the effective host name

Modified:
    jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java

Modified: jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java?rev=399735&r1=399734&r2=399735&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java
(original)
+++ jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java
Thu May  4 08:31:12 2006
@@ -247,7 +247,7 @@
         if (path.trim().equals("")) {
             path = PATH_DELIM;
         }
-        host = host.toLowerCase();
+        host = getEffectiveHost(host);
 
         HeaderElement[] headerElements =
                 HeaderElement.parseElements(header.toCharArray());
@@ -348,7 +348,7 @@
             if (cookie.getName().startsWith("$")) {
                 throw new MalformedCookieException("Cookie name may not start with $");
             }
-            CookieOrigin origin = new CookieOrigin(host, port, path, secure); 
+            CookieOrigin origin = new CookieOrigin(getEffectiveHost(host), port, path, secure);

             for (Iterator i = getAttribHandlerIterator(); i.hasNext(); ) {
               CookieAttributeHandler handler = (CookieAttributeHandler) i.next();
               handler.validate(cookie, origin);
@@ -381,7 +381,7 @@
             if (cookie.isPersistent() && cookie.isExpired()) {
                 return false;
             }
-            CookieOrigin origin = new CookieOrigin(host, port, path, secure); 
+            CookieOrigin origin = new CookieOrigin(getEffectiveHost(host), port, path, secure);

             for (Iterator i = getAttribHandlerIterator(); i.hasNext(); ) {
                 CookieAttributeHandler handler = (CookieAttributeHandler) i.next();
                 if (!handler.match(cookie, origin)) {
@@ -555,7 +555,7 @@
      * @return
      */
     private static String getEffectiveHost(final String host) {
-        String effectiveHost = host;
+        String effectiveHost = host.toLowerCase();
         if (host.indexOf('.') < 0) {
             effectiveHost += ".local";
         }
@@ -761,8 +761,7 @@
                 }
 
                 // The effective host name must domain-match domain attribute.
-                String effectiveHost = getEffectiveHost(host);
-                if (!domainMatch(effectiveHost, cookieDomain)) {
+                if (!domainMatch(host, cookieDomain)) {
                     throw new MalformedCookieException(
                             "Domain attribute \"" + cookie.getDomain()
                             + "\" violates RFC 2965: effective host name does not "
@@ -770,9 +769,8 @@
                 }
 
                 // effective host name minus domain must not contain any dots
-                String effectiveHostWithoutDomain =
-                        effectiveHost.substring(0, effectiveHost.length()
-                                                   - cookieDomain.length());
+                String effectiveHostWithoutDomain = host.substring(
+                        0, host.length() - cookieDomain.length());
                 if (effectiveHostWithoutDomain.indexOf('.') != -1) {
                     throw new MalformedCookieException("Domain attribute \""
                                                        + cookie.getDomain() + "\" violates
RFC 2965: "
@@ -802,17 +800,15 @@
             }
             String host = origin.getHost().toLowerCase();
             String cookieDomain = cookie.getDomain();
-            String effectiveHost = getEffectiveHost(host);
 
             // The effective host name MUST domain-match the Domain
             // attribute of the cookie.
-            if (!domainMatch(effectiveHost, cookieDomain)) {
+            if (!domainMatch(host, cookieDomain)) {
                 return false;
             }
             // effective host name minus domain must not contain any dots
-            String effectiveHostWithoutDomain =
-                    effectiveHost.substring(0, effectiveHost.length()
-                                               - cookieDomain.length());
+            String effectiveHostWithoutDomain = host.substring(
+                    0, host.length() - cookieDomain.length());
             if (effectiveHostWithoutDomain.indexOf('.') != -1) {
                 return false;
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message