-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cookielib chokes on non-integer cookie version, should ignore it instead #48174
Comments
PROBLEM: Some sites (e.g. https://itunesconnect.apple.com) sends cookies where PROBLEM CODE: 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: 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() |
The sensible fix for this is to strip the quotes off, defaulting to By the way, what you posted warning rather than a strictly unhandled FWIW, this bug only affects RFC 2109 cookies, not RFC 2965 cookies. |
Patch with tests attached. The patch is slightly different to my first |
The bug is present on trunk and on the py3k branch, so I've selected This is a straightforward bug, so I selected 2.5.3 and 2.6 also, to |
As the patch hasn't been applied to the trunk yet, I'm rejecting it for |
The cookiejar workaround in the first comment did not work for me. The 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) |
Thank you Henrik. The workaround in the first comment caused some It seems that the patch jjlee supplied should really be applied, |
Thanks for the patch! Applied in r81465 f. Merged to 2.x in r81467, will merge to 3k later. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: