diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 408ac6e7aed5a2e3d44af365e7e91fd68e9ddd1f..718e1c062eb2fae9cef9629365d5564cf3974e1f 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -50,6 +50,8 @@ [provided by Semantic MediaWiki](http://semantic-mediawiki.org/wiki/Ask_API). (by [@kyv](https://github.com/kyv)) [0a16afc](https://github.com/kyv/mwclient/commit/0a16afc) +* [2014-05-02] Quickfix for [https://github.com/mwclient/mwclient/issues/38 #38] + (by [@danmichaelo](https://github.com/danmichaelo)) ## Changes in version 0.6.5 Mwclient 0.6.5 was released on 6 May 2011 diff --git a/mwclient/http.py b/mwclient/http.py index cb2b2a8433e781d30a1fbe17b69ece37a9669848..1d3096481250eeafd35dfdee4083c5918c391694 100644 --- a/mwclient/http.py +++ b/mwclient/http.py @@ -27,9 +27,19 @@ class CookieJar(dict): return value, attrs = cookie.split(': ', 1)[1].split(';', 1) i = value.strip().split('=') - if len(i) == 1 and i[0] in self: + + # This CookieJar class doesn't care about the `expires` attribute, + # but remove cookies when they are emptied. At some point, the + # mediawiki API started setting the value of cookies to-be-removed + # to 'deleted' instead of emptying them. As a quick fix for + # <https://github.com/mwclient/mwclient/issues/38>, we will remove + # cookies with the value 'deleted' as well, but we should eventually + # replace this class, and probably the whole http class, by something + # more robust. The `requests` library looks like a promising candidate. + + if (len(i) == 1 and i[0] in self) or (len(i) == 2 and i[0] in self and i[1] == 'deleted'): del self[i[0]] - else: + elif len(i) == 2 and i[1] != 'deleted': self[i[0]] = i[1] def get_cookie_header(self):