mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-17 21:01:00 +00:00
Catch ValueError on invalid cookie expiration dates.
This commit is contained in:
parent
06a25676c5
commit
63cf8adf54
3 changed files with 25 additions and 1 deletions
|
|
@ -31,6 +31,9 @@ Fixes:
|
|||
- logging: Close logger properly on I/O errors.
|
||||
Closes: SF bug #3567476
|
||||
- checking: Fix wrong method name when printing SSL certificate warnings.
|
||||
- checking: Catch ValueError on invalid cookie expiration dates.
|
||||
Patch from Charles Jones.
|
||||
Closes: SF bug #3575556
|
||||
|
||||
|
||||
8.0 "Luminaris" (released 2.9.2012)
|
||||
|
|
|
|||
|
|
@ -119,7 +119,12 @@ class HttpCookie (object):
|
|||
# note: even self.now + maxage can overflow
|
||||
pass
|
||||
elif "expires" in self.attributes:
|
||||
self.expire = cookielib.http2time(self.attributes["expires"])
|
||||
expiration_date = self.attributes["expires"]
|
||||
try:
|
||||
self.expire = cookielib.http2time(expiration_date)
|
||||
except ValueError:
|
||||
# see http://bugs.python.org/issue16181
|
||||
raise CookieError("Invalid expiration date in %r" % expiration_date)
|
||||
|
||||
def is_expired (self, now=None):
|
||||
"""Return True if this cookie is expired, else False."""
|
||||
|
|
|
|||
|
|
@ -151,6 +151,22 @@ class TestCookies (unittest.TestCase):
|
|||
self.assertRaises(linkcheck.cookies.CookieError,
|
||||
linkcheck.cookies.NetscapeCookie, value, scheme, host, path)
|
||||
|
||||
def test_netscape_cookie9 (self):
|
||||
# illegal expiration date
|
||||
data = (
|
||||
("Foo", "Bar"),
|
||||
("Domain", "example.org"),
|
||||
("Expires", "Thu, 08-Oct-3697739 18:36:07 GMT"),
|
||||
("Path", "/"),
|
||||
)
|
||||
# note: values are without quotes
|
||||
value = "; ".join('%s=%s' % (key, value) for key, value in data)
|
||||
scheme = "http"
|
||||
host = "example.org"
|
||||
path = "/"
|
||||
self.assertRaises(linkcheck.cookies.CookieError,
|
||||
linkcheck.cookies.NetscapeCookie, value, scheme, host, path)
|
||||
|
||||
def test_rfc_cookie1 (self):
|
||||
data = (
|
||||
("Foo", "Bar"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue