jenkins-bot has submitted this change and it was merged.
Change subject: Ignore expired cookies ......................................................................
Ignore expired cookies
Bug: 63605 Change-Id: Ie04b1ecf43146eaaaa0253deecdb3347397b24a2 --- M login.py M wikipedia.py 2 files changed, 12 insertions(+), 2 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/login.py b/login.py index ebeccc7..ac0056c 100644 --- a/login.py +++ b/login.py @@ -59,6 +59,7 @@ import query import wikipedia as pywikibot import config +from datetime import datetime, timedelta
# On some wikis you are only allowed to run a bot if there is a link to # the bot's user page in a specific list. @@ -233,7 +234,7 @@ pywikibot.output(u"%s/%s\n%s" % (response.code, response.msg, fakeresponsemsg))
- Reat = re.compile(': (.*?)=(.*?);') + Reat = re.compile(': (.*?)=(.*?); (expires=(.*?);)?')
L = {} if hasattr(response, 'sheaders'): @@ -243,6 +244,10 @@ for eat in ck: m = Reat.search(eat) if m: + exps = m.group(4) + if exps: + if (datetime.strptime(exps, '%a, %d-%b-%Y %H:%M:%S %Z') - datetime.utcnow()) < timedelta(seconds=1): + continue L[m.group(1)] = m.group(2)
got_token = got_user = False diff --git a/wikipedia.py b/wikipedia.py index 13ee2ab..3d74d7b 100644 --- a/wikipedia.py +++ b/wikipedia.py @@ -7116,11 +7116,16 @@ else: ck = f.info().getallmatchingheaders('set-cookie') if ck: - Reat = re.compile(': (.*?)=(.*?);') + Reat = re.compile(': (.*?)=(.*?); (expires=(.*?);)?') tmpc = {} for d in ck: m = Reat.search(d) if m: + exps = m.group(4) + if exps: + if (datetime.datetime.strptime(exps, '%a, %d-%b-%Y %H:%M:%S %Z') + - datetime.datetime.utcnow()) < datetime.timedelta(seconds=1): + continue tmpc[m.group(1)] = m.group(2) if self.cookies(sysop): self.updateCookies(tmpc, sysop)