fix another bug in _check:cookies (#2160)

regression introduced in ed317bfc

Added a couple of tests to hopefully catch such bugs
before they land in a release.
This commit is contained in:
Mike Fährmann
2022-02-16 22:58:57 +01:00
parent c8414c9d95
commit f5b2b9333f
2 changed files with 91 additions and 5 deletions

View File

@@ -371,20 +371,25 @@ class Extractor():
for cookie in self._cookiejar:
if cookie.name in names and (
not domain or cookie.domain == domain):
if cookie.expires:
diff = int(cookie.expires - now)
if diff <= 0:
self.log.warning(
"Cookie '%s' has expired", cookie.name)
continue
elif diff <= 86400:
hours = diff // 3600
self.log.warning(
"Cookie '%s' will expire in less than %s hour%s",
cookie.name, hours + 1, "s" if hours else "")
else:
names.discard(cookie.name)
if not names:
return True
continue
names.discard(cookie.name)
if not names:
return True
return False
def _prepare_ddosguard_cookies(self):