[issue33017] Special set-cookie setting will bypass Cookielib

2022-02-10 Thread Adrian Chaves


Adrian Chaves  added the comment:

So, PoC shows how an empty domain attribute (Domain=) is erroneously turned 
into a dot (.).

I want to add that a dot (Domain=.) should be turned into an empty string (the 
specification asks to remove a leading dot if found).

--
nosy: +adrian2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

2020-04-06 Thread Liubomyr Popil


Liubomyr Popil  added the comment:

Hello,
I found this issue as most related to problem I was discovered:
a long name of day doesn't parsed.
According to https://tools.ietf.org/html/rfc2616#section-3.3.1:

  Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
  Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
  Sun Nov  6 08:49:37 1994   ; ANSI C's asctime() format

HTTP/1.1 clients and servers that parse the date value MUST accept
   all three formats (for compatibility with HTTP/1.0), though they MUST
   only generate the RFC 1123 format for representing HTTP-date values
   in header fields.

month format is correct, but for day part should be a both types.

Thanks,
 - Liubomyr

--
keywords: +patch
message_count: 6.0 -> 7.0
nosy: +lpopil
nosy_count: 3.0 -> 4.0
pull_requests: +18763
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/19393

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37858] CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file

2019-09-04 Thread Ned Deily


Change by Ned Deily :


--
versions:  -Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37858] CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file

2019-09-04 Thread Ashley Harvey


Change by Ashley Harvey :


--
pull_requests: +15340
pull_request: https://github.com/python/cpython/pull/15680

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37858] CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file

2019-09-04 Thread Ashley Harvey


Change by Ashley Harvey :


--
pull_requests: +15339
pull_request: https://github.com/python/cpython/pull/15679

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37858] CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file

2019-09-04 Thread Ashley Harvey


Change by Ashley Harvey :


--
keywords: +patch
pull_requests: +15338
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15673

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37858] CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file

2019-09-03 Thread Ashley Harvey


Change by Ashley Harvey :


--
versions: +Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37858] CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file

2019-08-14 Thread Ned Deily


Change by Ned Deily :


--
nosy:  -ned.deily

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37858] CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file

2019-08-14 Thread Ned Deily


Ned Deily  added the comment:

(removing the macOS component since presumably this behavior is not 
platform-dependent)

--
components:  -macOS
nosy:  -ronaldoussoren

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37858] CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file

2019-08-14 Thread Ashley Harvey


New submission from Ashley Harvey :

I'm on macOS 10.14.6, wget 1.20.3, python 2.7.

Command line:
$ wget --save-cookies cookies.txt --keep-session-cookies --post-data
'username=myUserName=myPassword' --delete-after 

Line 39 of _MozillaCookieJar.py (cookielib) shows it looking for 'magic_re = 
"#( Netscape)? HTTP Cookie File"' in order to validate the supplied cookies 
file.  Unlike cURL, wget however, produces a cookies file that begins with "# 
HTTP cookie file".  Note the lower-case c and f.  I reported this as a bug to 
the wget team who looked for the spec to say that that line must follow a 
certain format and couldn't find any such mention.  (See: 
https://savannah.gnu.org/bugs/?56755)

The lack of upper-case c and f cause cookielib to choke and stop processing
the cookies file, and so here I am reporting it as a bug that the regex is 
case-sensitive.

--
components: Library (Lib), macOS
messages: 349743
nosy: ashleyharvey, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate 
cookies file
type: behavior
versions: Python 2.7

___
Python tracker 
<https://bugs.python.org/issue37858>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33017] Special set-cookie setting will bypass Cookielib

2019-04-25 Thread Martin Panter

Martin Panter  added the comment:

I think LCatro is saying that Python should accept the cookies and discard only 
the offending attributes. This makes sense to me and tends to agree with the 
specifications, but the three cases seem all seem unimportant to me.

PoC 1, Max-age:

>>> from urllib2 import Request
>>> from test.test_cookielib import FakeResponse
>>> cookies = CookieJar(DefaultCookiePolicy())
>>> request = Request('http://127.0.0.1/requests_test.php')
>>> cookies.extract_cookies(FakeResponse(()), request)  # Issue 12144
>>> cookies.make_cookies(FakeResponse(('Set-Cookie: test=123; max-age=a',)), 
>>> request)  # No cookies returned
[]

RFC 6265 says Max-age should be ignored if not does not start with a digit or 
minus sign: . Netscape did 
not specify Max-age at all. So I agree that the cookie should be retained.

PoC 2, Domain: You have to omit the equals sign to satisfy “v is None” and 
discard the cookie record, otherwise “v” is just an empty string '':

>>> cookies.make_cookies(FakeResponse(('Set-Cookie: test=123; domain=;',)), 
>>> request)  # v == ''
[Cookie(version=0, name='test', value='123', port=None, port_specified=False, 
domain='.', domain_specified=True, domain_initial_dot=False, path='/', 
path_specified=False, secure=False, expires=None, discard=True, comment=None, 
comment_url=None, rest={}, rfc2109=False)]
>>> cookies.make_cookies(FakeResponse(('Set-Cookie: test=123; domain;',)), 
>>> request)  # v is None
[]

RFC 6265 says both these cases should be treated the same, and recommends 
ignoring Domain in these cases.

PoC 3, Version:

>>> cookies.make_cookies(FakeResponse(('Set-Cookie: test=123; version=a;',)), 
>>> request)  # No cookies returned
[]

The Version attribute is only specified by RFC 2109. Since the IETF has 
obsoleted it, I suggest to deprecate RFC 2109 support in the Python module. 
That way, if a real problem is demonstrated, we can remove the parts that are 
causing the problem.

--
nosy: +martin.panter
priority: normal -> low

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2019-04-13 Thread Inada Naoki


Inada Naoki  added the comment:

I don't think adding MSIE support is not worth enough for now.

--
nosy: +inada.naoki
resolution:  -> out of date
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

2018-10-10 Thread Martin Panter


Martin Panter  added the comment:

RFC 6265 says that only the first three letters of the month are significant, 
and the rest of the token should be ignored. See 
:

month = ( "jan" / "feb" / "mar" / "apr" /
"may" / "jun" / "jul" / "aug" /
"sep" / "oct" / "nov" / "dec" ) *OCTET

I have not heard of an Expires field syntax with a numeric month.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

2018-10-10 Thread Alberto Moral


Alberto Moral  added the comment:

Yes, I was thinking that it could be a matter of configuration of the server 
(?).

By the way, and just for fun, I've just realized that truncating mon at the 
begining of the _str2time funtion is a very bad idea because mon could also be 
an int.

A better place is when looking the MONTHS_LOWER array index (and possible 
exception is handle):
try:
mon = MONTHS_LOWER.index(mon[:3].lower())+1

(perhaps in 2 sentences for clarity)

OK, waiting for experts' comments.

I'm really enjoying Python.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

2018-10-10 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

No problem, I am also not an expert and I just skimmed through the RFC and 
cannot find any point related to month full name. So I just wanted to check if 
there are any recent changes I am missing or if the server is configured to set 
cookie expiration with full month name since there was no related issues raised 
as far as I have searched in the bug tracker. I will wait for others comment on 
this.

Thanks

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

2018-10-10 Thread Alberto Moral


Alberto Moral  added the comment:

Thanks for your answer. I have not found any RFCs with full month names either. 
I'm afraid I'm not an expert here.

But the case is that I get them in my work. Here is an example of response 
header:

  HTTP/1.1 200 OK
  Server: Oracle-iPlanet-Web-Server/7.0
  Date: Tue, 10 Oct 2018 14:29:44 GMT
  Version-auth-credencial: v.3.0.1 Iplanet - Sun Solaris - Contexto Multiple
  Set-cookie: JSESSIONIDE=Del; expires=Friday, 1-August-1997 00:00:00 GMT; 
domain=...

I do not know if it's an old date format (?)... or if it is a quite rare case...

I have created some previous bash scripts using wget and they work fine, but I 
have had problems with python3 (and requests module) till I realized this 
issue. And it was not very easy: I am very new with python :( 


That's the reason of my proposal. It's just to be coherent: if we compare 3 
letters of a month with MONTHS_LOWER, let's use just 3 (first) letters.

Perhaps modifying LOOSE_HTTP_DATE_RE is not a good idea. Another option could 
be to truncate the month variable (mon).

It could be done inside the _str2time funtion, for example:

def _str2time(day, mon, yr, hr, min, sec, tz):
mon = mon[:3]  # assure 3 letters
yr = int(yr)

Anyway, I'll try to find why those long month names appear.

Thank you

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

2018-10-10 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks for the report. As far as I can see from the RFC month seems to follow 
three letter code. Is there a part of RFC where Python is not compliant? I 
can't find any related issues or RFC links allowing month format specified in 
the report. Can you please add the relevant part of RFC or links if any? 

Date RFC 6265 5.1.1 : https://tools.ietf.org/html/rfc6265.html#section-5.1.1

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

2018-10-10 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

2018-10-10 Thread Alberto Moral


New submission from Alberto Moral :

http.cookiejar (cookielib, for python2.*) does not parse some cookies' Expires 
date.

For  example: "Friday, 1-August-1997 00:00:00 GMT" does not work (while: "Fri, 
01 Aug 1997 00:00:00 GMT" works fine)

This is basically due to long names of months (it is compared with 
MONTHS_LOWER: list of 3-letter months). So, I propose a small change in the 
definition of LOOSE_HTTP_DATE_RE (see fifth line):

LOOSE_HTTP_DATE_RE = re.compile(
r"""^
(\d\d?)# day
   (?:\s+|[-\/])
(\w{3})\w* # month (3 first letters only)
...

Instead of:
LOOSE_HTTP_DATE_RE = re.compile(
r"""^
(\d\d?)# day
   (?:\s+|[-\/])
(\w+)  # month
...

I've tested only http.cookiejar (python 3.6), but I suposse the same change 
will work on cookielib

Thanks in advance

--
components: Library (Lib)
messages: 327461
nosy: alb_moral
priority: normal
severity: normal
status: open
title: cookielib/cookiejar cookies' Expires date parse fails with long month 
names
type: behavior
versions: Python 2.7, Python 3.6

___
Python tracker 
<https://bugs.python.org/issue34951>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33017] Special set-cookie setting will bypass Cookielib

2018-03-18 Thread R. David Murray

R. David Murray  added the comment:

Can you explain what you think the problem is?  I don't know what your "POC" 
snippets are trying to demonstrate.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33017] Special set-cookie setting will bypass Cookielib

2018-03-06 Thread LCatro

New submission from LCatro <m4i1f0rt...@sina.cn>:

PoC (PHP Version):

 header('Set-Cookie: test=123; max-age=a');  //  PoC 1
 header('Set-Cookie: test=123; domain=;');  //  PoC 2
 header('Set-Cookie: test=123; version=a;');  //  PoC 3

PoC 1 will trigger int() convert string to number from max-age 
(lib/cookielib.py:1429).I give this value a string ,it will make except 

try:
v = int(v) #  lib/cookielib.py:1429
except ValueError:
_debug("   missing or invalid (non-numeric) value for "
  "max-age attribute")
bad_cookie = True
break  #  lib/cookielib.py:1434

PoC 2 is a domain None value (lib/cookielib.py:1412).Cookielib will discard 
current cookie record.
if k == "domain":  #  lib/cookielib.py:1411
if v is None:  #  lib/cookielib.py:1412
_debug("   missing value for domain attribute")
bad_cookie = True
break  #  lib/cookielib.py:1415

PoC 3 will trigger a int() convert except(lib/cookielib.py:1472).Cookielib will 
discard current cookie record too.
version = standard.get("version", None)  #  lib/cookielib.py:1469
if version is not None:
try:
version = int(version)  #  lib/cookielib.py:1472
except ValueError:
return None  # invalid version, ignore cookie

There are PoCs involve urllib and requests library .

Full Code Analysis (Chinese Version): 
https://github.com/lcatro/Python_CookieLib_0day

--
components: Library (Lib)
files: poc.php
messages: 313370
nosy: LCatro
priority: normal
severity: normal
status: open
title: Special set-cookie setting will bypass Cookielib
versions: Python 2.7
Added file: https://bugs.python.org/file47472/poc.php

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33017>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2017-09-07 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2017-09-03 Thread Cheryl Sabella

Cheryl Sabella added the comment:

Can this issue be closed?

--
nosy: +csabella

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21854] Fix cookielib in unicodeless build

2017-04-20 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
dependencies:  -Fix unicodeless build of Python
resolution:  -> rejected

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21854] Fix cookielib in unicodeless build

2017-04-20 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
dependencies: +Fix unicodeless build of Python
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2016-12-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5b40d81e8883 by Serhiy Storchaka in branch '2.7':
Issue #21818: Fixed references to classes that have names matching with module
https://hg.python.org/cpython/rev/5b40d81e8883

New changeset d64e37b9204e by Serhiy Storchaka in branch '3.5':
Issue #21818: Fixed references to classes that have names matching with module
https://hg.python.org/cpython/rev/d64e37b9204e

New changeset 62c9a89a2103 by Serhiy Storchaka in branch '3.6':
Issue #21818: Fixed references to classes that have names matching with module
https://hg.python.org/cpython/rev/62c9a89a2103

New changeset c642c597d05c by Serhiy Storchaka in branch 'default':
Issue #21818: Fixed references to classes that have names matching with module
https://hg.python.org/cpython/rev/c642c597d05c

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2016-11-29 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thus the only way to fix links is to specify full names? Does 
docs_class_links-2.7.patch look good to you?

--
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2015-11-09 Thread Georg Brandl

Georg Brandl added the comment:

The rules are as they are mostly for backwards compatibility. But it is rarely 
a problem since there is only one object with a given name.

:class:`Cookie` within the docs for cookielib would not be able to link to 
Cookie.Cookie since it is not found in its scope. :class:`Cookie.Cookie` works, 
as does :class:`~Cookie.Cookie`.

When you use the "find-in-any-namespace" syntax, i.e. :class:`.Cookie` the type 
*will* be taken into account.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21818>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2015-11-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Georg, is it possible to tune Sphinx rules?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2015-03-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch for 2.7 that fixes above a hundred of broken class references. 
But may be even more broken function references. I think it would be better to 
fix Sphinx rules.

--
keywords: +patch
priority: normal - high
Added file: http://bugs.python.org/file38485/docs_class_links-2.7.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21818
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2015-03-14 Thread R. David Murray

R. David Murray added the comment:

This happens because the role is pretty much ignored by Sphinx for linking 
purposes.  I remember Georg talking about the reason for this, but I forget 
what it was.  Perhaps it would be possible to, as you suggest, have the roll 
affect the priority...but it may be the case that the references don't 
currently retain the needed information.  Regardless, that would be an issue 
for the Sphinx tracker.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21818
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2015-03-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Georg, this looks as a bug in Sphinx configuration. Why module takes priority 
on class when the role is explicitly specified? I have counted about two 
hundreds of similar bugs in the documentation.

--
nosy: +georg.brandl, serhiy.storchaka
type:  - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21818
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-09-02 Thread Rebecka

Rebecka added the comment:

Akira is correct: using time.mktime to produce the expiration date for the 
cookie is wrong (thank you very much for the pointers!).

Using e.g. http.cookiejar.http2time with a HTTP formatted date string gives a 
correct time stamp (with which cookie.is_expired succeeds), so this was not a 
bug (just user error...).

--
resolution:  - not a bug
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-09-02 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
stage: needs patch - resolved

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-09-01 Thread Rebecka

Rebecka added the comment:

I've checked and an updated test file for 3.4 shows the same behaviour in the 
renamed module http.cookiejar.

Even though no standard exists I hope 3.4+ would be changed to simplify the 
cookie handling, since there is a lot of hassle converting UTC times to local 
times (which in general should be avoided to avoid introducing further problems 
with e.g. daylight savings).

--
Added file: http://bugs.python.org/file36519/cookie_timestamp_test_3.4.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-09-01 Thread Akira Li

Akira Li added the comment:

time.time() returns the current time in seconds since Epoch
it is neither local nor UTC time. It can be converted to both.

You can get local time using datetime.fromtimestamp(ts).
You can get UTC time using datetime.utcfromtimestamp(ts) or
to get an aware datetime object: datetime.fromtimestamp(ts, timezone.utc), 
where ts is the timestamp in seconds since Epoch.

I don't know whether there is an issue with cookie.is_expired() but it
is incorrect to use time.mktime() with UTC time tuple unless the local
time is UTC. To get the timestamp from a datetime object, you could
use .timestamp() method instead:

  from datetime import datetime, timezone

  now = datetime.now(timezone.utc) # the current time
  seconds_since_epoch = now.timestamp()
  seconds_since_epoch = time.time() # might be less precise

--
nosy: +akira

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-09-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Note the .timestamp() method will work correctly if the datetime object is 
expressed in *local time*, which is not what Rebecka's code uses. Otherwise the 
incantation is a bit more complex:

https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp

(also .timestamp() doesn't exist in 2.7, in which case the manual computation 
must also be used)

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-09-01 Thread Akira Li

Akira Li added the comment:

timestamp() method works correctly for an aware datetime objects
as in my example (notice: timezone.utc in the code).

The issue is not that it is a manual computation,
the issue is that it is incorrect:

  #XXX WRONG, DO NOT DO IT
  time.mktime(datetime.datetime.utcnow().timetuple())

On older Python versions, given a utc time as a naive datetime
object, POSIX timestamp is:

  ts = (utc_dt - datetime(1970, 1, 1)).total_seconds()
  utc_dt = datetime(1970, 1, 1) + timedelta(seconds=ts) # in reverse

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-09-01 Thread Akira Li

Akira Li added the comment:

The last example assumes that time.gmtime(0) is 1970-01-01 00:00:00Z
(otherwise time.time() may return different timestamp)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-08-29 Thread Rebecka

New submission from Rebecka:

The cookielib module uses time.time(), which produces a timestamp in the local 
timezone (as read from the system time?), as the timestamp against which 
expiration dates in cookies are compared.

However, typical usage of HTTP cookies would be specifying the expiration date 
in UTC. This assumption seems to be supported for example by the inclusion of 
cookielib.http2time, which (only) supports UTC timestamps.

This behaviour is also included in e.g. MozillaCookieJar, which (erroneously) 
excludes cookies from being saved/loaded based on the local timestamp from 
time.time().

See the attached file for a small example where the check if a cookie is 
expired against a UTC time is correct but the check against local time fails 
(simulating the behaviour of the cookielib module).

--
components: Library (Lib)
files: cookie_timestamp_test.py
messages: 226056
nosy: regu0004
priority: normal
severity: normal
status: open
title: cookielib uses time.time(), making incorrect checks of expiration times 
in cookies
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file36502/cookie_timestamp_test.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22296] cookielib uses time.time(), making incorrect checks of expiration times in cookies

2014-08-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

If you have not, please check if this issue applies to 3.4, and post a 3.4 
version of the test file.

In the absence of a standard, I am not sure if this is a bug, and even if we 
call it such, whether 2.7 should be changed.

--
nosy: +terry.reedy
stage:  - needs patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2008] cookielib lacks FileCookieJar class for Safari

2014-07-12 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy:  -berker.peksag

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2008
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21854] Fix cookielib in unicodeless build

2014-06-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Proposed patch fixes the cookielib module and it's tests for Python built with 
the --disable-unicode configure option.

--
components: Library (Lib), Tests
files: cookielib.patch
keywords: patch
messages: 221428
nosy: benjamin.peterson, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Fix cookielib in unicodeless build
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file35763/cookielib.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21854
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21854] Fix cookielib in unicodeless build

2014-06-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
dependencies: +Fix unicodeless build of Python

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21854
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2014-06-22 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy: +dbrecht

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21818
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21818] cookielib documentation references Cookie module, not cookielib.Cookie class

2014-06-20 Thread Angus Taggart

New submission from Angus Taggart:

all the links to Cookie class in the cookielib documentation point to Cookie 
module.


for example:

CookieJar.set_cookie(cookie)

Set a *Cookie*, without checking with policy to see whether or not it 
should be set.


cookie in the documentation links to
https://docs.python.org/2/library/cookie.html#module-Cookie

cookie in the documentation should link to
https://docs.python.org/2/library/cookielib.html#cookielib.Cookie

--
assignee: docs@python
components: Documentation
messages: 221133
nosy: Ajtag, docs@python
priority: normal
severity: normal
status: open
title: cookielib documentation references Cookie module, not cookielib.Cookie 
class
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21818
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2008] cookielib lacks FileCookieJar class for Safari

2014-02-05 Thread Hendrik

Changes by Hendrik hendrik.hoe...@googlemail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file33921/cookie.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2008
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2008] cookielib lacks FileCookieJar class for Safari

2014-02-05 Thread Hendrik

Changes by Hendrik hendrik.hoe...@googlemail.com:


Added file: http://bugs.python.org/file33922/cookiejar.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2008
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2008] cookielib lacks FileCookieJar class for Safari

2014-02-05 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +berker.peksag

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2008
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2008] cookielib lacks FileCookieJar class for Safari

2014-02-02 Thread Hendrik

Hendrik added the comment:

Ok, i've got it.

--- a/Lib/http/cookiejar.py Wed Dec 18 15:37:03 2013 -0600
+++ b/Lib/http/cookiejar.py Sat Feb 01 15:12:01 2014 +0100
@@ -11,17 +11,17 @@
 distributed with the Python standard library, but are available from
 http://wwwsearch.sf.net/):
 
-CookieJar
-/ \  \
-FileCookieJar  \  \
- /|   \ \  \
- MozillaCookieJar | LWPCookieJar \  \
-  |   |  \
-  |   ---MSIEBase |   \
-  |  /  | |\
-  | /   MSIEDBCookieJar BSDDBCookieJar
-  |/
-   MSIECookieJar
+ CookieJar
+/ \  \
+FileCookieJar  \  \
+   /   /  |   \ \  \
+SafariCookieJar   /   | LWPCookieJar \  \
+ /|   |  \
+   MozillaCookieJar   |   ---MSIEBase |   \
+  |  /  | |\
+  | /   MSIEDBCookieJar BSDDBCookieJar
+  |/
+  MSIECookieJar
 
 
 
@@ -31,8 +31,11 @@
 import copy
 import datetime
 import re
+import getpass
 import time
 import urllib.parse, urllib.request
+import struct
+import io
 try:
 import threading as _threading
 except ImportError:
@@ -40,6 +43,9 @@
 import http.client  # only for the default HTTP port
 from calendar import timegm
 
+import difflib
+#from difflib_data import *
+
 debug = False   # set to True to enable debugging via the logging module
 logger = None
 
@@ -1938,6 +1944,109 @@
 raise LoadError(invalid Set-Cookie3 format file %r: %r %
 (filename, line))
 
+class SafariCookieJar(FileCookieJar):
+
+Read Cookies from Safari
+
+
+def load(self, filename=None):
+if filename == None:
+username = getpass.getuser()
+path = '/Users/' + username + 
'/Library/Cookies/Cookies.binarycookies'
+else:
+path = filename
+
+bf=open(path,mode='rb')
+scook = bf.read(4).decode(UTF-8)
+if scook == 'cook':
+NumberOfPages=struct.unpack('i',bf.read(4))[0]
+page_sizes=[]
+for np in range(NumberOfPages):
+page_sizes.append(struct.unpack('i',bf.read(4))[0])
+pages=[]
+for ps in page_sizes:
+pages.append(bf.read(ps))
+
+for page in pages:
+page=io.BytesIO(page)
+page.read(4)
+num_cookies=struct.unpack('i',page.read(4))[0]
+cookie_offsets=[]
+for nc in range(num_cookies):
+cookie_offsets.append(struct.unpack('i',page.read(4))[0])
+
+page.read(4)
+
+cookie=''
+for offset in cookie_offsets:
+page.seek(offset)
+cookiesize=struct.unpack('i',page.read(4))[0]
+cookie=io.BytesIO(page.read(cookiesize))
+
+cookie.read(4)
+
+flags=struct.unpack('i',cookie.read(4))[0]
+cookie_flags=''
+if flags==0:
+cookie_flags=''
+elif flags==1:
+cookie_flags='Secure'
+elif flags==4:
+cookie_flags='HttpOnly'
+elif flags==5:
+cookie_flags='Secure; HttpOnly'
+else:
+cookie_flags='Unknown'
+
+cookie.read(4)
+
+urloffset=struct.unpack('i',cookie.read(4))[0]
+nameoffset=struct.unpack('i',cookie.read(4))[0]
+pathoffset=struct.unpack('i',cookie.read(4))[0]
+valueoffset=struct.unpack('i',cookie.read(4))[0]
+
+endofcookie=cookie.read(8)
+
+expiry_date_epoch= 
struct.unpack('d',cookie.read(8))[0]+978307200
+expiry_date=time.strftime(%a, %d %b %Y 
,time.gmtime(expiry_date_epoch))[:-1]
+
+
create_date_epoch=struct.unpack('d',cookie.read(8))[0]+978307200
+create_date=time.strftime(%a, %d %b %Y 
,time.gmtime(create_date_epoch))[:-1]
+
+cookie.seek(urloffset-4)
+url=''
+u=cookie.read(1)
+while struct.unpack('b',u)[0]!=0:
+url=url+u.decode('UTF-8')
+u=cookie.read(1)
+
+cookie.seek(nameoffset-4)
+name=''
+n=cookie.read(1)
+while struct.unpack('b',n)[0]!=0:
+ 

[issue2008] cookielib lacks FileCookieJar class for Safari

2014-02-02 Thread Hendrik

Changes by Hendrik hendrik.hoe...@googlemail.com:


--
versions: +Python 3.4 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2008
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2008] cookielib lacks FileCookieJar class for Safari

2014-02-01 Thread Hendrik

Hendrik added the comment:

I found a solution for reading Safari cookies, but struggling around with hg 
diff. Because always when i typ hg diff Lib/http/cookiejar.py it returns me the 
complete file not only my changes..

--
nosy: +Hendrik

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2008
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



newbie needs help with cookielib

2011-05-04 Thread Sells, Fred
I'm using Python 2.4 and 2.7 for different apps.  I'm happy with a
solution for either one.

I've got to talk to a url that uses a session cookie.  I only need to
set this when I'm developing/debugging so I don't need a robust
production solution and I'm somewhat confused by the docs on cookielib.
I can use urllib2 without cookielib just fine, but need the cookie to
add some security.

I'm normally using Firefox 4.0 to login to the server and get the
cookie.  After that I need some way to set the same cookie in my python
script.  I can do this by editing my code, since I only need it while
defeloping from my test W7 box.


I was hoping to find something like

...set_cookie('mycookiename', 'myvalue', 'mydomain.org')

I've googled this most of the morning and found everything but what I
need, or I just don't understand the basic concept.  Any pointers would
be greatly appreciated.  One of my false starts looks like this. But I
get a 

...
  File C:\alltools\python26\lib\urllib2.py, line 518, in
http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Access Deinied

def test1():
cj = cookielib.MozillaCookieJar()
cj.load('C:/Users/myname/Desktop/cookies.txt')
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
r = opener.open(http://daffyduck.mydomain.org/wsgi/myapp.wsgi;)   
print r.read() 
return

-- 
http://mail.python.org/mailman/listinfo/python-list


[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2007
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-07-24 Thread Mark Lawrence

Mark Lawrence breamore...@yahoo.co.uk added the comment:

Can we have the patch committed to 2.7 and 3.1 please.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-07-20 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

Hmm, I never tested with Python 3, though I assume the forward-port was 
straightforward.  The patch was created against (2.x) trunk, so indeed it 
should be committed there also.

Deselecting 2.6 since I assume no more maintenance backports will be made to 
2.6 aside from security fixes -- right?

--
versions:  -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-07-20 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Until 2.6.6 is released bug fixes can still be backported to 2.6 but it is at 
the committer's option.  Most likely this one won't be.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-07-19 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

My patch should be applied.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-07-19 Thread Mark Lawrence

Mark Lawrence breamore...@yahoo.co.uk added the comment:

Patched the unit test, then ran the test before applying the fix which failed, 
after applying the fix the test ran successfully.  Tested on Windows Vista 32 
bit against 2.7 maintainance release.  The patches are short and sweet, I see 
no reason why they can't go forward.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-07-19 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

jjlee's issue3704.patch has been committed to py3k (3.2) in r82985.  It could 
still use backporting to 2.6, 2.7 and 3.1.

--
resolution:  - accepted
versions:  -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-07-18 Thread Mark Lawrence

Mark Lawrence breamore...@yahoo.co.uk added the comment:

Could we please have an update from people who have been involved on this issue 
as to whether it can be taken forward, closed as to no longer relevant, or 
whatever.

--
nosy: +BreamoreBoy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2010-07-10 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Removed file was a dup of msg62113 Jansen  2008-02-06 13:34

FileCookieJars are now in http.cookiejar. Doc says The following CookieJar 
subclasses are provided for reading and writing . Further CookieJar subclasses, 
including one that reads Microsoft Internet Explorer cookies, are available at 
http://wwwsearch.sf.net/ClientCookie/.;

Link does not work and appears to be superseded by
http://wwwsearch.sourceforge.net/mechanize/

If this issue is closed, at least that doc change should be made.

--
nosy: +tjreedy
versions: +Python 3.2 -Python 2.6, Python 3.0

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2007
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2010-07-10 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

Suggest removing the comment that Terry refers to.  That referenced MSIE code 
doesn't have an automated test, I've no idea whether it still works on modern 
Windows OSes, mechanize no longer supports use with urllib2, and I don't think 
that link is really appropriate in the docs anyway -- Google will likely give 
people more accurate information.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2007
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2010-07-10 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

I removed the documentation comment in r82785. But the report still holds till 
we have a class for handling MSIE Cookies.

--
nosy: +orsenthil
stage:  - needs patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2007
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2008] cookielib lacks FileCookieJar class for Safari

2010-07-09 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions: +Python 3.2 -Python 2.6, Python 3.0

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2008
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2010-07-09 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


Removed file: http://bugs.python.org/file9362/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2007
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2010-05-22 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Thanks for the patch!  Applied in r81465 f.  Merged to 2.x in r81467, will 
merge to 3k later.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-11 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

What specific breakage do you expect resulting from my patch being backported?

There is no behaviour change here, except to the minimal extent that all bug 
fixes involve behaviour change.  This seems a clear-cut backport candidate.

It's not a surprise to me that changing module urlparse to be compliant with 
RFC 3986 breaks code -- I suggested adding a new module instead for that reason.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-11 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I don't expect anything; I had written that it looked OK to me but apparently I 
accidentally deleted that text before posting.  But I'm not someone who has 
ever programmed using cookielib so I wouldn't expect my opinion to count for 
too much.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-11 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

There is a reason, and that is that it may break existing code in the field 
relying on the current behavior.  This is (unfortunately) true regardless of 
whether the function is public or private, though the fact that it is 
ostensibly private is likely to reduce the amount of breakage.  The fix needs 
to be evaluated to try to guess whether breakage is likely, and if it is, it 
would not be a candidate for backport to 2.6 or 3.1.

--
nosy: +r.david.murray
versions: +Python 2.7, Python 3.1, Python 3.2 -Python 3.0

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-11 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Hmm.  I didn't read your comment carefully enough before I replied.  I think 
you are saying that the bug fix is confined to the routine in question and 
doesn't change even its API, in which case the nature of the function doesn't 
come in to it at all.  The fix still needs to be evaluated for backport, 
though, since it is a behavior change.  (For example, in another issue Senthil 
fixed parsing of unknown schemes to be RFC compliant, but we may need to back 
that fix out of 2.6 since it changes behavior and will most likely break 
currently working 2.6 code).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-10 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

I'll upload a patch when I'm back home (bugs.python.org went down yesterday).

Will turn docstring into comment.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-10 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

Just re-read your comment, Tres.  Since when do docstrings determine whether a 
stdlib function is public?  If it's documented in the docs, it's public.  If 
not, it's not.  This function isn't, so it's not public.  It's also not in 
__all__, FWLTW.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-10 Thread John J Lee

Changes by John J Lee jj...@users.sourceforge.net:


Added file: http://bugs.python.org/file17285/issue3704.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-10 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

Didn't bother changing docstring to comment, since that would be inconsistent 
with rest of module.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-10 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

FWIW, the certain semantics that request_path promises are 1. that it 
returns the RFC 2965 request-URI (which has never been true -- it returns the 
path component of the request-URI instead) and 2. that that request-URI is as 
defined in RFC 2965, and this bug is about fixing the function so that that's 
true for the case where the URI has a query component.  So there's absolutely 
no reason for not changing the function.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-09 Thread John J Lee

John J Lee jj...@users.sourceforge.net added the comment:

It looks to me that it's just request_path that's wrong, so no need to add 
extra arguments to that function.  It should discard the query and fragment 
(still keeping the parameters -- using urlparse.urlsplit instead of 
urlparse.urlparse would make that simpler).

request_path is only called in three places:

 * We're agreed that the default cookie path should omit the query (and 
fragment)
 * Netscape cookies aren't checked for path on setting cookies 
(.set_ok_path()), so the value of request_path isn't checked in that case
 * Netscape cookies are checked for path on returning cookies, but including 
the query  fragment will never make a difference to the .startswith check in 
.path_return_ok()

Finally, even RFC 2965, which nobody cares about, and which does include the 
path check on setting the cookie, refers to RFC 2396 for the definition of 
request-URI, and both RFC 2396 and RFC 3986, which obsoletes it, agree that the 
path doesn't include the query (nor the fragment).

Incidentally: the request_path function docstring claims to return the 
request-URI, but obviously the docstring should say it returns the path 
component of the request-URI.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-09 Thread Tres Seaver

Tres Seaver tsea...@agendaless.com added the comment:

As long as we don't care about preserving backward compatibility, we
could indeed just change the behavior of 'request_path'.  It isn't
documented as an API of the cookielib module, but it does have a
docstring which promises certain semantics.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2010-05-02 Thread Tres Seaver

Tres Seaver tsea...@agendaless.com added the comment:

I can confirm that the patch applies cleanly to the release26-maint
branch, and that the updated test fails without the updated
implementation.

However, the entire approach seems wrong to me:  the patched method
has just called 'request_path', which already cracked the URL using
urlparse.urlparse and put it back together again with
urlparse.urlunparse.

A better fix would be either to call urlparse.urlparse directly, or
else to add an argument to 'request_path' which kept it from doing the
unwanted reassembly.

Attaching a patch which implements the latter strategy.  Greg's new
test passes with this patch applied in place of the part of his patch
which touches Lib/cookielib.py.

--
nosy: +tseaver
Added file: http://bugs.python.org/file17187/issue3704-better_request_path.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[2.5.1/cookielib] How to display specific cookie?

2010-04-07 Thread Gilles Ganault
Hello

I'm using ActivePython 2.5.1 and the cookielib package to retrieve web
pages.

I'd like to display a given cookie from the cookiejar instead of the
whole thing:


#OK
for index, cookie in enumerate(cj):
print index, '  :  ', cookie

#How to display just PHPSESSID?
#AttributeError: CookieJar instance has no attribute '__getitem__'
print PHPSESSID: %s % cj['PHPSESSID']


I'm sure it's very simple but googling for this didn't return samples.

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2009-11-24 Thread Andrew Shuiu

Changes by Andrew Shuiu as...@bitdefender.com:


--
versions: +Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2009-04-08 Thread Andy Sk

Andy Sk python...@bitjug.com added the comment:

Thank you Henrik.  The workaround in the first comment caused some
cookies to be handled incorrectly due to ignoring version on all
cookies, but your workaround is nice.  

It seems that the patch jjlee supplied should really be applied,
however, to save others from having this problem.

--
nosy: +andysk

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2009-03-02 Thread Henrik Olsson

Henrik Olsson henr...@wip.se added the comment:

The cookiejar workaround in the first comment did not work for me. The
cookies didn't stick in it. I guess version needs to be set.. this
worked for me:

class ForgivingCookieJar(cookielib.CookieJar):
def _cookie_from_cookie_tuple(self, tup, request):
name, value, standard, rest = tup
version = standard.get(version, None)
if version is not None:
# Some servers add  around the version number, this module
expects a pure int.
standard[version] = version.strip('')
return cookielib.CookieJar._cookie_from_cookie_tuple(self, tup,
request)

--
nosy: +henriko

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2009-02-12 Thread Daniel Diniz

Changes by Daniel Diniz aja...@gmail.com:


--
components: +Library (Lib) -None
stage:  - patch review
versions:  -Python 2.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2009-02-12 Thread Daniel Diniz

Changes by Daniel Diniz aja...@gmail.com:


--
stage:  - patch review
versions:  -Python 2.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5059] Policy.DomainStrict in cookielib example code

2009-02-05 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Thanks, fixed in r69293.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5059
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5059] Policy.DomainStrict in cookielib example code

2009-01-25 Thread Attila Babo

New submission from Attila Babo attila.b...@gmail.com:

Example code at the bottom of cookielib documentation has an error:
policy = DefaultCookiePolicy(
rfc2965=True, strict_ns_domain=Policy.DomainStrict,
blocked_domains=[ads.net, .ads.net])

The corrected version is
policy = DefaultCookiePolicy(
rfc2965=True, strict_ns_domain= DefaultCookiePolicy.DomainStrict,
blocked_domains=[ads.net, .ads.net])

--
assignee: georg.brandl
components: Documentation
messages: 80535
nosy: babo, georg.brandl
severity: normal
status: open
title: Policy.DomainStrict in cookielib example code
type: compile error
versions: Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5059
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[cookielib] How to add cookies myself?

2008-12-16 Thread Gilles Ganault
Hello

I'm using urllib and urlib to download data from a web server that
requires cookies.

The issue I'm having, is the server uses JavaScript in the response to
insert new cookies and send them with the next query, so I need to
manually add a couple of cookies in the CookieJar, but I don't know
how to do this and Google didn't return examples:

=
import urllib
import urllib2
import cookielib

headers = {'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows
NT)'}
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)

url = http://www.acme.com/index.php;
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req).read()

print Fetched cookies:
for index, cookie in enumerate(cj):
print index, '  :  ', cookie


How to Add manually?
crm_cookieEnabled=1
ctr=1

=

Thanks for any tip.
--
http://mail.python.org/mailman/listinfo/python-list


[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2008-12-10 Thread Martin v. Löwis

Martin v. Löwis [EMAIL PROTECTED] added the comment:

As the patch hasn't been applied to the trunk yet, I'm rejecting it for
2.5.3.

--
nosy: +loewis
versions:  -Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2008-10-25 Thread John J Lee

John J Lee [EMAIL PROTECTED] added the comment:

Patch with tests attached.  The patch is slightly different to my first
suggestion: in the patch, invalid version values cause the cookie to be
ignored (but double quotes around valid versions are fine).

--
keywords: +patch
Added file: http://bugs.python.org/file11888/issue3924.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2008-10-25 Thread John J Lee

John J Lee [EMAIL PROTECTED] added the comment:

The bug is present on trunk and on the py3k branch, so I've selected
versions Python 2.7 and Python 3.0

This is a straightforward bug, so I selected 2.5.3 and 2.6 also, to
indicate this is a candidate for backport.

--
components: +Library (Lib) -None
type: crash - behavior
versions: +Python 2.5.3, Python 2.6, Python 2.7, Python 3.0

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2008-10-16 Thread John J Lee

John J Lee [EMAIL PROTECTED] added the comment:

Forgot to add: if somebody else does the work, I'm happy to agree to the
code being used in Python stdlib.  Perhaps it would be necessary to get
the author of the original Perl code from which this MSIE class is
derived to sign a contributor agreement, though (even though he already
agreed to a BSD-ish license).

FWIW, there's also a Firefox 3 cookies.sqlite cookiejar in the same
package (though not yet used in anger by me, and wanting more tests, so
marked experimental).

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2007
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2008-10-15 Thread John J Lee

John J Lee [EMAIL PROTECTED] added the comment:

Note that the code on wwwsearch.sf.net only reads cookies, and does not
write them.  Also, the approach used is fragile to changes to MS's
index.dat database, which was the reason why that code was not
included when cookielib was added.  As far as I know, the index.dat
format is not specified and is subject to change or removal by MS.  It's
possible that that MSIE cookiejar is already broken on Windows Vista,
for example, since I have never tested it on that platform.

An alternative approach that should allow writing cookies would be to
use InternetGetCookie / InternetSetCookie API:

http://msdn.microsoft.com/en-us/library/aa384710(VS.85).aspx

A *sketch* of that approach (which I'm not going to implement properly)
is here:

http://codespeak.net/svn/wwwsearch/mechanize/trunk/attic/MSIEDBCookieJar.py

The other, fragile (but working, at least on some MS OSes) approach:

http://codespeak.net/svn/wwwsearch/mechanize/trunk/mechanize/_msiecookiejar.py

--
nosy: +jjlee

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2007
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2008-10-15 Thread John J Lee

John J Lee [EMAIL PROTECTED] added the comment:

Do we have an RFC 3986 URI parser in the stdlib now?  It would be better
to use that if so, but I don't see one.  Failing that, an implementation
of the relevant part of that RFC is only about four lines of code, so
that would be better than naively looking for ? (request_path should
probably be changed at the same time).

I'll try and add a patch that does that and check what Firefox does to
see if I agree it's a bug.

--
nosy: +jjlee

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2008-10-15 Thread John J Lee

John J Lee [EMAIL PROTECTED] added the comment:

The sensible fix for this is to strip the quotes off, defaulting to
version 0 on failure to parse the version cookie-attribute.  It's not
necessary to retain the original version string.

By the way, what you posted warning rather than a strictly unhandled
exception or crash -- it's a bug, but won't cause the program to stop.
 And by none of the cookies work after that, you mean that no cookies
in headers containing the quoted version cookie-attribute are accepted
by the cookiejar.

FWIW, this bug only affects RFC 2109 cookies, not RFC 2965 cookies.

--
nosy: +jjlee

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3704] cookielib doesn't handle URLs with / in parameters

2008-10-15 Thread Senthil

Senthil [EMAIL PROTECTED] added the comment:

John, issue3647 tries relative url parsing and joins to be RFC3986
compliance.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Cookielib in Jython

2008-10-06 Thread Felipe De Bene
Hi There,
I'm trying to run an App I wrote in Python 2.5.2 in Jython 2.2.1 and
everything works fine except when I try to import the Standard
CPython's cookielib. I know this may sound stupid, I could use an
advice here on what's wrong. Thanks in advance,
Felipe.

Output:
Jython 2.2.1 on java1.6.0_07
Type copyright, credits or license for more information.
 import cookielib
Traceback (innermost last):
  File console, line 1, in ?
ImportError: no module named cookielib
 from cookielib import *
Traceback (innermost last):
  File console, line 1, in ?
ImportError: no module named cookielib
 from CookieLib import *
Traceback (innermost last):
  File console, line 1, in ?
ImportError: no module named CookieLib
--
http://mail.python.org/mailman/listinfo/python-list


Re: Cookielib in Jython

2008-10-06 Thread bieffe62
On 6 Ott, 13:19, Felipe De Bene [EMAIL PROTECTED] wrote:
 Hi There,
 I'm trying to run an App I wrote in Python 2.5.2 in Jython 2.2.1 and
 everything works fine except when I try to import the Standard
 CPython's cookielib. I know this may sound stupid, I could use an
 advice here on what's wrong. Thanks in advance,
 Felipe.

 Output:
 Jython 2.2.1 on java1.6.0_07
 Type copyright, credits or license for more information. import 
 cookielib

 Traceback (innermost last):
   File console, line 1, in ?
 ImportError: no module named cookielib from cookielib import *

 Traceback (innermost last):
   File console, line 1, in ?
 ImportError: no module named cookielib from CookieLib import *

 Traceback (innermost last):
   File console, line 1, in ?
 ImportError: no module named CookieLib

Obviously, choockielib is not in your jython installation.
If this module is a pure python module and not a wrupper of an
underlying C
module, you could try simple to get is from a CPython installation,
try and
compile it with Jython inside the code. If the module does not use any
feature
of the language introduced after Python 2.2, or other unsupported
modules,
it could work and you can use it inside your program as it was one of
your modules.

HTH

FB
--
http://mail.python.org/mailman/listinfo/python-list


Re: Cookielib in Jython

2008-10-06 Thread Felipe De Bene
On Oct 6, 10:36 am, [EMAIL PROTECTED] wrote:
 On 6 Ott, 13:19, Felipe De Bene [EMAIL PROTECTED] wrote:



  Hi There,
  I'm trying to run an App I wrote in Python 2.5.2 in Jython 2.2.1 and
  everything works fine except when I try to import the Standard
  CPython's cookielib. I know this may sound stupid, I could use an
  advice here on what's wrong. Thanks in advance,
  Felipe.

  Output:
  Jython 2.2.1 on java1.6.0_07
  Type copyright, credits or license for more information. import 
  cookielib

  Traceback (innermost last):
    File console, line 1, in ?
  ImportError: no module named cookielib from cookielib import *

  Traceback (innermost last):
    File console, line 1, in ?
  ImportError: no module named cookielib from CookieLib import *

  Traceback (innermost last):
    File console, line 1, in ?
  ImportError: no module named CookieLib

 Obviously, choockielib is not in your jython installation.
 If this module is a pure python module and not a wrupper of an
 underlying C
 module, you could try simple to get is from a CPython installation,
 try and
 compile it with Jython inside the code. If the module does not use any
 feature
 of the language introduced after Python 2.2, or other unsupported
 modules,
 it could work and you can use it inside your program as it was one of
 your modules.

 HTH
 
 FB

Thanks that worked :D
--
http://mail.python.org/mailman/listinfo/python-list


[issue3924] cookielib chokes on non-integer cookie version, should ignore it instead

2008-09-21 Thread Denis

New submission from Denis [EMAIL PROTECTED]:

PROBLEM:

Some sites (e.g. https://itunesconnect.apple.com) sends cookies where
version is 1 instead of 1. Cookielib chokes on it so none of the
cookies work after that.

PROBLEM CODE:
def _cookie_from_cookie_tuple(self, tup, request):
...
name, value, standard, rest = tup
...
version = standard.get(version, None)
if version is not None: version = int(version)  CRASH HERE!!!



WORKAROUND:

use my own cookie jar, e.g.:

class MyCookieJar(CookieJar):
def _cookie_from_cookie_tuple(self, tup, request):
name, value, standard, rest = tup
standard[version]= None
CookieJar._cookie_from_cookie_tuple(self, tup, request)

REAL FIX:
do not assume that version is int, keep it as string if it does not
parse as int:

CRASH STACK:

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/cookielib.py:1577:
UserWarning: cookielib bug!
Traceback (most recent call last):
  File
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/cookielib.py,
line 1575, in make_cookies
parse_ns_headers(ns_hdrs), request)
  File
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/cookielib.py,
line 1532, in _cookies_from_attrs_set
cookie = self._cookie_from_cookie_tuple(tup, request)
  File
/Users/denis/Documents/svn2/tson/main/sales/src/download_sales.py,
line 28, in _cookie_from_cookie_tuple
CookieJar._cookie_from_cookie_tuple(self, tup, request)
  File
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/cookielib.py,
line 1451, in _cookie_from_cookie_tuple
if version is not None: version = int(version)
ValueError: invalid literal for int() with base 10: '1'

  _warn_unhandled_exception()

--
components: None
messages: 73518
nosy: DenNukem
severity: normal
status: open
title: cookielib chokes on non-integer cookie version, should ignore it instead
type: crash
versions: Python 2.5

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3924
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >