From f6bd9e08bf16165f1ae2a7c98255fd89709a72a9 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Mon, 27 Dec 2010 21:40:22 -0700 Subject: remove talk_to_socket and all its associated bits --- docs/README.cookies | 63 ----------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 docs/README.cookies (limited to 'docs') diff --git a/docs/README.cookies b/docs/README.cookies deleted file mode 100644 index 148603f..0000000 --- a/docs/README.cookies +++ /dev/null @@ -1,63 +0,0 @@ -# Cookies and Uzbl # - -The speed of cookie lookups is important, since a single page load can involve -dozens of HTTP requests, each of which needs a separate cookie lookup (since -another instance of uzbl may have obtained new cookies for a site). - -It is possible handle cookie lookup (and storage) using a `spawn_async` cookie -handler, but spawning new processes is inherently slow so a `talk_to_socket` -cookie daemon (like the default uzbl-cookie-manager) is recommended. - -## uzbl-cookie-manager ## - -uzbl-cookie-manager is a cookie daemon based on libsoup's SoupCookieJar. Cookies -are stored in a file in the Mozilla cookies.txt format (default location -$XDG_DATA_HOME/.local/share/cookies.txt). - -### uzbl-cookie-manager Whitelist ### - -If a whitelist file is present (default location -$XDG_CONFIG_HOME/uzbl/cookie_whitelist), then website attempts to set cookies -will be ignored unless the site's domain is present in the whitelist. - -The whitelist can contain comment lines beginning with `#`, and domain lines. A -domain line beginning with . will whitelist the given domain name and any -subdomain of it. Otherwise only exact matches of the domain are whitelisted. - -For instance, given this whitelist file: - - example.com - .uzbl.org - -uzbl-cookie-manager would accept cookies for example.com, uzbl.org and -www.uzbl.org, but ignore cookies set for www.example.com (and any other -domain that is not a subdomain of uzbl.org). - -## uzbl-cookie-daemon ## - -uzbl-cookie-daemon is a Python cookie daemon based on Python's cookielib. -Cookielib's lookup algorithm isn't very efficient for our needs, so -uzbl-cookie-daemon is noticeably slow. - -## Cookie Daemon Protocol ## - -When uzbl's `cookie_handler` variable is set to `talk_to_socket path`, uzbl -connects to the Unix domain socket located at `path`. uzbl will send a cookie -lookup request on this socket every time it makes an HTTP request. The format of -this lookup request is: - - GET\0scheme\0host\0path\0 - -where `\0` is the null character, `scheme` is the URL scheme (http or https), -`host` is the hostname from the URL and `path` is the requested path. The cookie -daemon should respond with the names and values of cookies that match the -request, in the format used by the `Cookie` header, terminated with a `\0`. - -When a website adds, deletes or changes a cookie, uzbl notifies the cookie -daemon with a request in the format: - - PUT\0scheme\0host\0path\0name=value\0 - -where `scheme`, `host` and `path` are (approximately) as above, and `name=value` -is the cookie name-value pair to store. The cookie daemon should respond by -writing `\0` to the socket. -- cgit v1.2.3 From 6a737a7137c8cfbbe21bb5f0c0182ca2255a5b4c Mon Sep 17 00:00:00 2001 From: keis Date: Mon, 17 Jan 2011 21:37:08 +0100 Subject: multiple components/re -pairs in cookie filters --- README | 4 ++-- docs/README.uzbl-event-manager | 20 ++++++++++---------- examples/config/config | 6 +++++- examples/data/plugins/cookies.py | 28 ++++++++++++++++++---------- 4 files changed, 35 insertions(+), 23 deletions(-) (limited to 'docs') 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 `: Blacklist cookies where + - `request BLACKLIST_COOKIE [ ]*`: Blacklist cookies where `` matches ``. `` 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 `: Whitelist cookies where + - `request WHITELIST_COOKIE [ ]*`: Whitelist cookies where `` matches ``. `` 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 - 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 [ ]* + 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 - 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 [ ]* + 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: -- cgit v1.2.3