W3C home > Mailing lists > Public > www-jigsaw@w3.org > March to April 2007

RE: Cookie parsing issue...

From: Laird, Brian <BLaird@havigs.com>
Date: Tue, 20 Mar 2007 08:42:51 -0500
Message-ID: <198C7B6593B76E44B30C3AAC456E57A1027B168A@electra.Perseco.com>
To: "Yves Lafon" <ylafon@w3.org>
Cc: <www-jigsaw@w3.org>, "Mrozinski, Ken" <KMrozinski@havigs.com>

Hey Yves,

Well I spent some time trying to implement your fix and here is what I found:

The problem actually exists in the HttpParser.  What I think is happening is that the third call to the parser (from the HttpCookieList class) to get the value of the cookie is stopping on the equals sign because that is the delimiter.

I think this is easier to explain via an example.  Below is an example cookie header.

Cookie: HGS$$LocaleCookie=en_US; CHALLENGE_COOKIE=Y3hBsq1lr9AxMTE2; CARDTYPE=card

The first call to the parse routine using the cv (ParseState) yields the following:

This is correct.  The next call to the parse routine using the it variable (ParseState) yields the following which is the name of cookie.  Now the it variable was initialized with the equals sign as the separator.


The third call to the parse routine is where we lose the equals sign.  The routine returns the following: 


In the HttpParser, as it runs through the bytes it is checking to see if it hit the separator.  Once it does find the separator it assumes it is complete.  

Now I looked to see how to fix this and I am kind of at a loss.  Here is what we did try to do:

- Tried implementing your fix but that resulted in an infinite loop.  I think that has to do with how the ParseState is keeping track of the position in the raw bytes and then where the separator shows up.  

- Create a new ParseState object with a separator that would never be found in a cookie.  Unfortunately, we could never get it work correctly.  I don't think we set the start & end variables correctly.

- Change the existing it variables separator to something that would never be found in a cookie.  Again that didn't work right.

- We looked at just rewriting the whole parse routine but we were afraid that we will introduce some bugs that you have long since resolved due to browser compatibility type stuff.

We are perfectly willing to do the work if you could just provide some direction as to how best to resolve this issue.

Thanks again for the help,

-----Original Message-----
From: Yves Lafon [mailto:ylafon@w3.org] 
Sent: Friday, March 16, 2007 7:50 AM
To: Laird, Brian
Cc: www-jigsaw@w3.org
Subject: Re: Cookie parsing issue...

On Fri, 16 Mar 2007, Yves Lafon wrote:

> On Fri, 16 Mar 2007, Laird, Brian wrote:
>> I hope things are well; it has been a while since we have talked.  We
>> came across a problem I am hoping you (or someone who knows the jigsaw
>> code well) can help us with.  In a majority of our processing we are
>> using some randomly generated cookie values from a third party as kind
>> of a session identifier.  Well a few days ago the value being generated
>> started to look like this (without the double quotes):
>> "0_0RbEAwflUxOTIxNjgyMDMzMw==".  We also store this value in memory and
>> compare it to the cookie when the user comes back to our site.

Ok, I located the issue, the parsing is done in 
org.w3c.www.http.HttpCookieList, in parse(), the parser has '=' as a 
separator, hence the issue you see.

you can try to change


StringBuffer sb = new StringBuffer(it.toString(raw));
while (HttpParser.nextItem(raw, it) < 0 ) {

and see if that fixes the issue.

Baroula que barouleras, au tiéu toujou t'entourneras.


This e-mail and any accompanying documents or files contain information that is the 
property of HAVI Global Solutions, that is intended solely for those to whom this e-mail is addressed 
(i.e., those identified in the "To" and "Cc" boxes), and that is confidential, proprietary, 
and/or privileged.  If you are not an intended recipient of this e-mail, you are hereby 
notified that any viewing, use, disclosure, forwarding, copying, or distribution of any of 
this information is strictly prohibited and may be subject to legal sanctions.  If you have 
received this e-mail in error, please notify the sender immediately of any unintended 
recipients, and delete the e-mail, all attachments, and all copies of both from your system.

While we have taken reasonable precautions to ensure that any attachments to this e-mail 
have been swept for viruses, we cannot accept liability for any damage sustained as a 
result of software viruses.
Received on Tuesday, 20 March 2007 13:40:58 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:25:40 UTC