----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------


I've run into some cookie interoperability problems between JServ and
perl-based CGI programs that other people/projects in my company are
using.  The problem is that the JServ cookie parser is treating space
as a separator, so a cookie header like:

Cookie: foo=null; something=hello world; yow=ugh;

does not seem to be interpreted correctly according to RFC2109.  JServ
servlets end up with a cookie "something" with value "hello" and 
a cookie "world" with no value.

Looking at JServUtil.java, it appears that the use of StringTokenizer
is the problem:
 
   StringTokenizer stok = new StringTokenizer(cookieHdr, "; ");

I think the above does not mean "split up the string using semi-colon
and space as a token separator."  It means "split the string using
either semi-colon or space as a token separator."

Anyway, here's a patch that we've been using successfully for about
two months.  Sorry it took me so long to post it.

cheers,

-billo

--- JServUtils.java     Wed Jun  7 15:17:53 2000
***************
*** 162,174 ****
          if(cookieHdr == null || cookieHdr.length() == 0)
              return new Cookie[0];
  
!         StringTokenizer stok = new StringTokenizer(cookieHdr, "; ");
          while (stok.hasMoreTokens()) {
              try {
                  String tok = stok.nextToken();
                  int equals_pos = tok.indexOf('=');
                  if (equals_pos > 0) {
                      String name = tok.substring(0, equals_pos);
                      String value = tok.substring(equals_pos + 1);
                      cookieJar.addElement(new Cookie(name, value));
                  }
--- 162,175 ----
          if(cookieHdr == null || cookieHdr.length() == 0)
              return new Cookie[0];
  
!         StringTokenizer stok = new StringTokenizer(cookieHdr, ";");
          while (stok.hasMoreTokens()) {
              try {
                  String tok = stok.nextToken();
                  int equals_pos = tok.indexOf('=');
                  if (equals_pos > 0) {
                      String name = tok.substring(0, equals_pos);
+                     name = name.trim();
                      String value = tok.substring(equals_pos + 1);
                      cookieJar.addElement(new Cookie(name, value));
                  }



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to