Skip to content
Snippets Groups Projects
Commit 98b850b2 authored by Dan Michael O. Heggø's avatar Dan Michael O. Heggø
Browse files

[#38] Quickfix for cookies not being removed from CookieJar

parent ed1aea5e
No related branches found
No related tags found
Loading
......@@ -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
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment