You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Steve McAdams <St...@oracle.com> on 2005/01/31 19:58:07 UTC

Problem with MarshalCookie

While fiddling around with mod_pyhon 3.1.3 MarshalCookies and IE6, I 
noticed that once a cookie got to a certain size, it would stop being 
recognized as a valid Marshal cookie.  I suspect (although I don't know 
for sure -- I'm not currently in a position to build mod_python) the 
problem is the following:

In MarshalCookie's "def __str__(self):" method, base64.encodestring() is 
used to encode the cookie value.  Unfortunately, base64.encodestring() 
adds newline characters to the byte stream every 76th byte, which seem 
to cause the problem.  The terminal newline is stripped, but none of the 
internal ones.

I would suggest that the line:
m = base64.encodestring(marshal.dumps(self.value))[:-1]

be replaced by something like:
m = base64.encodestring(marshal.dumps(self.value))
m = "".join(m.split("\n"))

Regards, Steve McAdams




Re: Problem with MarshalCookie

Posted by Nicolas Lehuen <ni...@gmail.com>.
On Mon, 31 Jan 2005 10:58:07 -0800, Steve McAdams
<St...@oracle.com> wrote:
> While fiddling around with mod_pyhon 3.1.3 MarshalCookies and IE6, I
> noticed that once a cookie got to a certain size, it would stop being
> recognized as a valid Marshal cookie.  I suspect (although I don't know
> for sure -- I'm not currently in a position to build mod_python) the
> problem is the following:
> 
> In MarshalCookie's "def __str__(self):" method, base64.encodestring() is
> used to encode the cookie value.  Unfortunately, base64.encodestring()
> adds newline characters to the byte stream every 76th byte, which seem
> to cause the problem.  The terminal newline is stripped, but none of the
> internal ones.
> 
> I would suggest that the line:
> m = base64.encodestring(marshal.dumps(self.value))[:-1]
> 
> be replaced by something like:
> m = base64.encodestring(marshal.dumps(self.value))
> m = "".join(m.split("\n"))
> 
> Regards, Steve McAdams

Hi,

You're perfectly right, and so is your fix. I have integrated it in
the subversion repository, and it will be released in the next
official release (on which we are working right now).

Thanks for reporting this bug !

Regards,
Nicolas