commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r240442 - in /jakarta/commons/proper/httpclient/trunk/src: java/org/apache/commons/httpclient/util/ test/org/apache/commons/httpclient/ test/org/apache/commons/httpclient/cookie/
Date Sat, 27 Aug 2005 18:08:07 GMT
Author: olegk
Date: Sat Aug 27 11:07:59 2005
New Revision: 240442

URL: http://svn.apache.org/viewcvs?rev=240442&view=rev
Log:
PR #36140 (ParameterParser parse method for authentication headers does not appear to deal
with empty value strings)

ParameterParser changed to correctly differentiate between empty and null (no value) parameters

Contributed by Oleg Kalnichevski
Reviewed by Ortwin Gl├╝ck

Modified:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/ParameterParser.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestHeaderElement.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestParameterParser.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieCompatibilitySpec.java

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/ParameterParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/ParameterParser.java?rev=240442&r1=240441&r2=240442&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/ParameterParser.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/ParameterParser.java
Sat Aug 27 11:07:59 2005
@@ -96,7 +96,7 @@
             }
         }
         String result = null;
-        if (i2 > i1) {
+        if (i2 >= i1) {
             result = new String(chars, i1, i2 - i1);
         }
         return result;

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestHeaderElement.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestHeaderElement.java?rev=240442&r1=240441&r2=240442&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestHeaderElement.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestHeaderElement.java
Sat Aug 27 11:07:59 2005
@@ -86,7 +86,7 @@
         // 1st element has 2 getParameters()
         assertEquals(2,elements[0].getParameters().length);
         assertEquals("name2",elements[0].getParameters()[0].getName());
-        assertTrue(null == elements[0].getParameters()[0].getValue());
+        assertEquals(null, elements[0].getParameters()[0].getValue());
         assertEquals("name3",elements[0].getParameters()[1].getName());
         assertEquals("value3",elements[0].getParameters()[1].getValue());
         // 2nd element
@@ -98,7 +98,7 @@
         assertEquals("value5",elements[1].getParameters()[0].getValue());
         // 3rd element
         assertEquals("name6",elements[2].getName());
-        assertEquals(null,elements[2].getValue());
+        assertEquals("",elements[2].getValue());
         // 3rd element has 2 getParameters()
         assertEquals(2,elements[2].getParameters().length);
         assertEquals("name7",elements[2].getParameters()[0].getName());

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestParameterParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestParameterParser.java?rev=240442&r1=240441&r2=240442&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestParameterParser.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestParameterParser.java
Sat Aug 27 11:07:59 2005
@@ -60,7 +60,6 @@
         return new TestSuite(TestParameterParser.class);
     }
 
-
     public void testParsing() {
         String s = 
           "test; test1 =  stuff   ; test2 =  \"stuff; stuff\"; test3=\"stuff";
@@ -82,7 +81,7 @@
         assertEquals("test1", ((NameValuePair)params.get(1)).getName());
         assertEquals("stuff", ((NameValuePair)params.get(1)).getValue());
         assertEquals("test2", ((NameValuePair)params.get(2)).getName());
-        assertEquals(null, ((NameValuePair)params.get(2)).getValue());
+        assertEquals("", ((NameValuePair)params.get(2)).getValue());
         assertEquals("test3", ((NameValuePair)params.get(3)).getName());
         assertEquals(null, ((NameValuePair)params.get(3)).getValue());
 
@@ -121,5 +120,17 @@
                 ((NameValuePair)params.get(1)).getName());
         assertNull(
                 ((NameValuePair)params.get(1)).getValue());
-    }    
+    }
+    
+    public void testParsingBlankParams() {
+        String s =  "test; test1 =  ; test2 = \"\"";
+        ParameterParser  parser = new ParameterParser();
+        List params = parser.parse(s, ';');
+        assertEquals("test", ((NameValuePair)params.get(0)).getName());
+        assertEquals(null, ((NameValuePair)params.get(0)).getValue());
+        assertEquals("test1", ((NameValuePair)params.get(1)).getName());
+        assertEquals("", ((NameValuePair)params.get(1)).getValue());
+        assertEquals("test2", ((NameValuePair)params.get(2)).getName());
+        assertEquals("", ((NameValuePair)params.get(2)).getValue());
+    }
 }

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieCompatibilitySpec.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieCompatibilitySpec.java?rev=240442&r1=240441&r2=240442&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieCompatibilitySpec.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieCompatibilitySpec.java
Sat Aug 27 11:07:59 2005
@@ -389,7 +389,7 @@
         Cookie[] parsed = cookieParse(cookiespec, "127.0.0.1", 80, "/", false, header);
         assertEquals("Found 1 cookie.",1,parsed.length);
         assertEquals("Name","cookie-name",parsed[0].getName());
-        assertTrue("Value",null == parsed[0].getValue());
+        assertEquals("Value", "", parsed[0].getValue());
         assertTrue("Comment",null == parsed[0].getComment());
         assertTrue("ExpiryDate",null == parsed[0].getExpiryDate());
         //assertTrue("isToBeDiscarded",parsed[0].isToBeDiscarded());



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