aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README4
-rw-r--r--docs/README.uzbl-event-manager20
-rw-r--r--examples/config/config6
-rw-r--r--examples/data/plugins/cookies.py28
4 files changed, 35 insertions, 23 deletions
diff --git a/README b/README
index a8c500c..d20cbd2 100644
--- a/README
+++ b/README
@@ -770,12 +770,12 @@ Events/requests which the EM and its plugins listens for
move the cursor back by one character.
* `START_COMPLETION`: TODO explain completion
* `BLACKLIST_COOKIE`: add a rule for blacklisting cookies
- - `request BLACKLIST_COOKIE <component> <regexp>`: Blacklist cookies where
+ - `request BLACKLIST_COOKIE [<component> <regexp>]*`: Blacklist cookies where
`<component>` matches `<regexp>`. `<component>` is one of `domain`,
`path`, `name`, `value`, `scheme` or `expires`.
* `WHITELIST_COOKIE`: add a rule for whitelisting cookies (if any whitelist is
set then only cookies that are whitelisted cookies will be used)
- - `request WHITELIST_COOKIE <component> <regexp>`: Whitelist cookies where
+ - `request WHITELIST_COOKIE [<component> <regexp>]*`: Whitelist cookies where
`<component>` matches `<regexp>`. `<component>` is one of `domain`,
`path`, `name`, `value`, `scheme` or `expires`.
diff --git a/docs/README.uzbl-event-manager b/docs/README.uzbl-event-manager
index 074811e..b9467d7 100644
--- a/docs/README.uzbl-event-manager
+++ b/docs/README.uzbl-event-manager
@@ -83,17 +83,17 @@ events. If any whitelist is set, then any cookie that is not whitelisted will
be rejected. Otherwise, only cookies that have been blacklisted will be
rejected.
-BLACKLIST_COOKIE <part> <re>
- Adds a new blacklist filter. cookies where the component specified by
- `part` matches the regular expression `re` will be filtered. part can be
- either 0-5 or any of the symbolic names domain, path, name, value, scheme,
- expires
+BLACKLIST_COOKIE [<component> <re>]*
+ Adds a new blacklist filter. cookies where the components specified by
+ `component` matches the regular expression `re` will be filtered. component
+ may be either 0-5 or any of the symbolic names domain, path, name, value,
+ scheme, expires
- for example to block all cookies which name is "__utm" followed by a single
+ for example to block all cookies which name is "__utm" followed by a single
character (google analytics cookies) do.
request BLACKLIST_COOKIE name '^__utm.$'
-WHITELIST_COOKIE <part> <re>
- Adds a new whitelist filter. cookies where the component specified by
- `part` matches the regular expression `re` will be allowed. part can be any
- of the parts allowed for the BLACKLIST_COOKIE event
+WHITELIST_COOKIE [<component> <re>]*
+ Adds a new whitelist filter. cookies where the components specified by
+ `component` matches the regular expression `re` will be allowed. component
+ may be any of the components allowed for the BLACKLIST_COOKIE event
diff --git a/examples/config/config b/examples/config/config
index a2ecdb8..bdf1c00 100644
--- a/examples/config/config
+++ b/examples/config/config
@@ -129,7 +129,11 @@ set progress.pending =
set useragent = Uzbl (Webkit @{WEBKIT_MAJOR}.@{WEBKIT_MINOR}) (@(+uname -sm)@ [@ARCH_UZBL])
# === Configure cookie blacklist ========================================================
-# Drop google analytics tracking cookies
+
+# Accept 'session cookies' from uzbl.org (when you have a whitelist all other cookies are dropped)
+#request WHITELIST_COOKIE domain 'uzbl.org$' expires '^$'
+
+# Drop google analytics tracking cookies (applied after whitelists if any)
#request BLACKLIST_COOKIE name '^__utm.$'
# === Key binding configuration ==============================================
diff --git a/examples/data/plugins/cookies.py b/examples/data/plugins/cookies.py
index 9eccace..6ee8798 100644
--- a/examples/data/plugins/cookies.py
+++ b/examples/data/plugins/cookies.py
@@ -106,8 +106,11 @@ DefaultStore = TextStore(os.path.join(xdg_data_home, 'uzbl/cookies.txt'))
SessionStore = TextStore(os.path.join(xdg_data_home, 'uzbl/session-cookies.txt'))
def match_list(_list, cookie):
- for component, match in _list:
- if match(cookie[component]) is not None:
+ for matcher in _list:
+ for component, match in matcher:
+ if match(cookie[component]) is None:
+ break
+ else:
return True
return False
@@ -158,18 +161,21 @@ def delete_cookie(uzbl, cookie):
store.delete_cookie(cookie, splitted)
# add a cookie matcher to a whitelist or a blacklist.
-# a matcher is a (component, re) tuple that matches a cookie when the
+# a matcher is a list of (component, re) tuples that matches a cookie when the
# "component" part of the cookie matches the regular expression "re".
# "component" is one of the keys defined in the variable "symbolic" above,
# or the index of a component of a cookie tuple.
def add_cookie_matcher(_list, arg):
- component, regexp = splitquoted(arg)
- try:
- component = symbolic[component]
- except KeyError:
- component = int(component)
- assert component <= 5
- _list.append((component, re.compile(regexp).search))
+ args = splitquoted(arg)
+ mlist = []
+ for (component, regexp) in zip(args[0::2], args[1::2]):
+ try:
+ component = symbolic[component]
+ except KeyError:
+ component = int(component)
+ assert component <= 5
+ mlist.append((component, re.compile(regexp).search))
+ _list.append(mlist)
def blacklist(uzbl, arg):
add_cookie_matcher(uzbl.cookie_blacklist, arg)
@@ -188,3 +194,5 @@ def init(uzbl):
'cookie_blacklist' : [],
'cookie_whitelist' : []
})
+
+# vi: set et ts=4: