aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar keis <keijser@gmail.com>2011-01-01 03:01:48 +0100
committerGravatar keis <keijser@gmail.com>2011-01-01 03:01:48 +0100
commit15c83d8a85a150f46e80f7fc97041f10a43a96df (patch)
tree91939d5b770d379fc292b0a32ef42ebd8f9ae94f
parentf6bd9e08bf16165f1ae2a7c98255fd89709a72a9 (diff)
malformed cookie rows pass through delete
-rw-r--r--examples/data/plugins/cookies.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/examples/data/plugins/cookies.py b/examples/data/plugins/cookies.py
index c9fe2c3..9eccace 100644
--- a/examples/data/plugins/cookies.py
+++ b/examples/data/plugins/cookies.py
@@ -38,24 +38,38 @@ class TextStore(object):
self.filename = filename
def as_event(self, cookie):
+ """Convert cookie.txt row to uzbls cookie event format"""
+ scheme = {
+ 'TRUE' : 'https',
+ 'FALSE' : 'http'
+ }
if cookie[0].startswith("#HttpOnly_"):
domain = cookie[0][len("#HttpOnly_"):]
elif cookie[0].startswith('#'):
return None
else:
domain = cookie[0]
- return (domain,
- cookie[2],
- cookie[5],
- cookie[6],
- 'https' if cookie[3] == 'TRUE' else 'http',
- cookie[4])
+ try:
+ return (domain,
+ cookie[2],
+ cookie[5],
+ cookie[6],
+ scheme[cookie[3]],
+ cookie[4])
+ except (KeyError,IndexError):
+ # Let malformed rows pass through like comments
+ return None
def as_file(self, cookie):
+ """Convert cookie event to cookie.txt row"""
+ secure = {
+ 'https' : 'TRUE',
+ 'http' : 'FALSE'
+ }
return (cookie[0],
'TRUE' if cookie[0].startswith('.') else 'FALSE',
cookie[1],
- 'TRUE' if cookie[4] == 'https' else 'FALSE',
+ secure[cookie[4]],
cookie[5],
cookie[2],
cookie[3])