commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestCookie.java
Date Mon, 20 Oct 2003 22:27:37 GMT
olegk       2003/10/20 15:27:37

  Modified:    httpclient/src/java/org/apache/commons/httpclient/cookie
                        Tag: HTTPCLIENT_2_0_BRANCH CookieSpecBase.java
               httpclient/src/test/org/apache/commons/httpclient Tag:
                        HTTPCLIENT_2_0_BRANCH TestCookie.java
  Log:
  PR# 23866 (Invalid cookie causing IllegalArgumentException)
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.16.2.1  +14 -10    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java
  
  Index: CookieSpecBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java,v
  retrieving revision 1.16
  retrieving revision 1.16.2.1
  diff -u -r1.16 -r1.16.2.1
  --- CookieSpecBase.java	12 Jun 2003 19:12:16 -0000	1.16
  +++ CookieSpecBase.java	20 Oct 2003 22:27:37 -0000	1.16.2.1
  @@ -189,13 +189,17 @@
           for (int i = 0; i < headerElements.length; i++) {
   
               HeaderElement headerelement = headerElements[i];
  -            Cookie cookie = new Cookie(host,
  -                                       headerelement.getName(),
  -                                       headerelement.getValue(),
  -                                       defaultPath, 
  -                                       null,
  -                                       false);
  -
  +            Cookie cookie = null;
  +            try {
  +                cookie = new Cookie(host,
  +                                    headerelement.getName(),
  +                                    headerelement.getValue(),
  +                                    defaultPath, 
  +                                    null,
  +                                    false);
  +            } catch (IllegalArgumentException e) {
  +                throw new MalformedCookieException(e.getMessage()); 
  +            }
               // cycle through the parameters
               NameValuePair[] parameters = headerelement.getParameters();
               // could be null. In case only a header element and no parameters.
  
  
  
  No                   revision
  No                   revision
  1.22.2.1  +12 -10    jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java
  
  Index: TestCookie.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java,v
  retrieving revision 1.22
  retrieving revision 1.22.2.1
  diff -u -r1.22 -r1.22.2.1
  --- TestCookie.java	12 Jun 2003 19:12:16 -0000	1.22
  +++ TestCookie.java	20 Oct 2003 22:27:37 -0000	1.22.2.1
  @@ -786,10 +786,11 @@
       public void testInvalidCookieName() {
           try
           {
  -            Cookie dummy = new Cookie("localhost", "invalid name", "cooke name may not
have blanks");
  -            fail("IllegalArgumentException must have been thrown");
  +            CookieSpec parser = new CookieSpecBase();
  +            parser.parse("localhost", 80, "/", false, "invalid name="); 
  +            fail("MalformedCookieException must have been thrown");
           }
  -        catch(IllegalArgumentException e)
  +        catch(MalformedCookieException e)
           {
               // Expected            
           }
  @@ -802,10 +803,11 @@
       public void testInvalidCookieName2() {
           try
           {
  -            Cookie dummy = new Cookie("localhost", "$invalid_name", "cooke name may not
start with $");
  -            fail("IllegalArgumentException must have been thrown");
  +            CookieSpec parser = new CookieSpecBase();
  +            parser.parse("localhost", 80, "/", false, "$invalid_name="); 
  +            fail("MalformedCookieException must have been thrown");
           }
  -        catch(IllegalArgumentException e)
  +        catch(MalformedCookieException e)
           {
               // Expected            
           }
  
  
  

---------------------------------------------------------------------
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