浏览代码

Determine which cookies apply to which domains better.

tags/v0.1^2
Ben Kurtovic 12 年前
父节点
当前提交
c19a1bde2e
共有 1 个文件被更改,包括 5 次插入8 次删除
  1. +5
    -8
      earwigbot/wiki/site.py

+ 5
- 8
earwigbot/wiki/site.py 查看文件

@@ -25,7 +25,6 @@ from gzip import GzipFile
from json import loads
from logging import getLogger, NullHandler
from os.path import expanduser
from re import escape as re_escape, match as re_match
from StringIO import StringIO
from threading import Lock
from time import sleep, time
@@ -394,15 +393,13 @@ class Site(object):
if user_name:
return unquote_plus(user_name.value)

name = "centralauth_Token"
for cookie in self._cookiejar:
if not cookie.domain_initial_dot or cookie.is_expired():
if cookie.name != "centralauth_Token" or cookie.is_expired():
continue
if cookie.name != name:
continue
# Build a regex that will match domains this cookie affects:
search = ''.join(("(.*?)", re_escape(cookie.domain)))
if re_match(search, self.domain): # Test it against our site
base = cookie.domain
if base.startswith(".") and not cookie.domain_initial_dot:
base = base[1:]
if self.domain.endswith(base):
user_name = self._get_cookie("centralauth_User", cookie.domain)
if user_name:
return unquote_plus(user_name.value)


正在加载...
取消
保存