Browse Source

Apparently cookie values are plus-quoted. Oops!

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
46c3561ce8
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      earwigbot/wiki/site.py

+ 4
- 4
earwigbot/wiki/site.py View File

@@ -29,7 +29,7 @@ from re import escape as re_escape, match as re_match
from StringIO import StringIO from StringIO import StringIO
from threading import Lock from threading import Lock
from time import sleep, time from time import sleep, time
from urllib import quote_plus
from urllib import quote_plus, unquote_plus
from urllib2 import build_opener, HTTPCookieProcessor, URLError from urllib2 import build_opener, HTTPCookieProcessor, URLError
from urlparse import urlparse from urlparse import urlparse


@@ -170,7 +170,7 @@ class Site(object):
self._login_info = name, password = login self._login_info = name, password = login
if name and password: if name and password:
logged_in_as = self._get_username_from_cookies() logged_in_as = self._get_username_from_cookies()
if not logged_in_as or name != logged_in_as:
if not logged_in_as or name.replace("_", " ") != logged_in_as:
self._login(login) self._login(login)


def __repr__(self): def __repr__(self):
@@ -392,7 +392,7 @@ class Site(object):
name = ''.join((self._name, "UserName")) name = ''.join((self._name, "UserName"))
user_name = self._get_cookie(name, self.domain) user_name = self._get_cookie(name, self.domain)
if user_name: if user_name:
return user_name.value
return unquote_plus(user_name.value)


name = "centralauth_Token" name = "centralauth_Token"
for cookie in self._cookiejar: for cookie in self._cookiejar:
@@ -405,7 +405,7 @@ class Site(object):
if re_match(search, self.domain): # Test it against our site if re_match(search, self.domain): # Test it against our site
user_name = self._get_cookie("centralauth_User", cookie.domain) user_name = self._get_cookie("centralauth_User", cookie.domain)
if user_name: if user_name:
return user_name.value
return unquote_plus(user_name.value)


def _get_username_from_api(self): def _get_username_from_api(self):
"""Do a simple API query to get our username and return it. """Do a simple API query to get our username and return it.


Loading…
Cancel
Save