problems with module Cookie

Manlio Perillo NOmanlio_perilloSPAM at libero.it
Sun May 23 12:03:11 EDT 2004


On Sun, 23 May 2004 10:08:15 +0000 (UTC), Jarek Zgoda
<jzgoda at gazeta.usun.pl> wrote:

>Manlio Perillo <NOmanlio_perilloSPAM at libero.it> pisze:
>
>>>> I'm using the Cookie module (on the client side).
>> 
>> ^^^
>>>> I have found a problem trying to parse the cookie:
>>>> 
>>>> "Set-Cookie: value=thevalue; path=/; 
>>>>                         expires=Fri, 21-May-2004 10:40:51 GMT"
>>>
>>>You must use date in UTC format.
>> 
>> This is the date format used by the server cookie!
>
>See http://www.w3.org/TR/NOTE-datetime on how should date look in
>cookies. If date is not in valid format, the module functions may have
>trouble decoding it.

It is not a my problem!
The web server  follow the Netscape specification for Cookies and in
this spec the date is in the format I have posted.

I'm trying to fix the regular expression patternin Cookie.py but it
does not work:


_LegalCharsPatt  = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]"

_DatePatt = r"(?:\D{3}, \d{2}-\D{3}-\d{4} \d{2}:\d{2}:\d{2} GMT)" <---

_CookiePattern = re.compile(
    r"(?x)"     
    r"(?P<key>" 
    ""+ _LegalCharsPatt +"+?"
    r")"  
    r"\s*=\s*"  
    r"(?P<val>"  
    r'"(?:[^\\"]|\\.)*"'
    r"|"  
    ""+ _DatePatt + ""                  <-------------
    r"|" 
    ""+ _LegalCharsPatt +"*" 
    r")" 
    r"\s*;?"
    )



Thanks and regards   Manlio Perillo



More information about the Python-list mailing list