diff options
author | Brendan Taylor <whateley@gmail.com> | 2009-07-13 17:00:18 -0600 |
---|---|---|
committer | Brendan Taylor <whateley@gmail.com> | 2009-07-13 17:00:18 -0600 |
commit | f90cf21c5561a4ae2b282d6e095c38d06f38840e (patch) | |
tree | 747f47f402caa8b2ba8b28ae911cd51093713b12 | |
parent | f52c73418f9a68bde9d2668e5215960a0f20cbcf (diff) | |
parent | e4ec794daa2a27f4476f53aacbf947f57a27ce5c (diff) |
Merge branch 'experimental' of git://github.com/Dieterbe/uzbl into replace-expand-template
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | docs/CONTRIBUTING | 12 | ||||
-rwxr-xr-x | examples/data/uzbl/scripts/cookies.py | 94 | ||||
-rwxr-xr-x | examples/data/uzbl/scripts/cookies.sh | 1 | ||||
-rw-r--r-- | uzbl.c | 4 |
5 files changed, 41 insertions, 77 deletions
@@ -316,9 +316,10 @@ The script specific arguments are this: * cookie handler $8 GET/PUT - $9 request address host (if current page url is www.foo.com/somepage, this could be something else than foo, eg advertising from another host) - $10 request address path - $11 cookie (only with PUT requests) + $9 request address scheme (e.g. http or https) + $10 request address host (if current page url is www.foo.com/somepage, this could be something else than foo, eg advertising from another host) + $11 request address path + $12 cookie (only with PUT requests) Custom, userdefined scripts (`spawn foo bar`) get first the arguments as specified in the config and then the above 7 are added at the end. diff --git a/docs/CONTRIBUTING b/docs/CONTRIBUTING index 14c3f0b..f5d7ebc 100644 --- a/docs/CONTRIBUTING +++ b/docs/CONTRIBUTING @@ -69,6 +69,18 @@ This is a relatively easy, solid and transparent way to handle all requests in o That said, you can always ask us to check on your stuff or ask for advice. +### Bugreporting + +Bug reports are also welcome, especially the ones that come with a patch ;-) +Before making a new ticket, check whether the bug is reported already. +If you want to report a bug and you don't know where the problem in the code +is, please supply: + +* version (commit hash) (see `uzbl --version`) +* operating system +* versions of libsoup, webkit, gtk. +* output of uzbl --verbose (with http_debug set, if relevant) + ### Valgrind profiling $ add this to Makefile header: CFLAGS=-g $ recompile diff --git a/examples/data/uzbl/scripts/cookies.py b/examples/data/uzbl/scripts/cookies.py index c8cf8c0..10f90fa 100755 --- a/examples/data/uzbl/scripts/cookies.py +++ b/examples/data/uzbl/scripts/cookies.py @@ -1,87 +1,37 @@ #!/usr/bin/env python -import cookielib, sys, os, urllib2 - -class FakeRequest: - def __init__(self, argv): - self.argv = argv - self.cookies = None - if len(self.argv) == 12: - self.cookies = self.argv[11] - def get_full_url(self): - #TODO: this is a hack, fix in uzbl.c! - u = self.get_host()+self.argv[10] - if self.argv[6].startswith('https'): - u = 'https://'+u - else: - u = 'http://'+u - return u - def get_host(self): - return self.argv[9] - def get_type(self): - return self.get_full_url().split(':')[0] - def is_unverifiable(self): - return False - def get_origin_req_host(self): - return self.argv[9] - def has_header(self, header): - if header == 'Cookie': - return self.cookies!=None - def get_header(self, header_name, default=None): - if header_name == 'Cookie' and self.cookies: - return self.cookies - else: - return default - def header_items(self): - if self.cookies: - return [('Cookie',self.cookies)] - else: - return [] - def add_unredirected_header(self, key, header): - if key == 'Cookie': - self.cookies = header - -class FakeHeaders: - def __init__(self, argv): - self.argv = argv - def getallmatchingheaders(self, header): - if header == 'Set-Cookie' and len(self.argv) == 12: - return ['Set-Cookie: '+self.argv[11]] - else: - return [] - def getheaders(self, header): - if header == 'Set-Cookie' and len(self.argv) == 12: - return [self.argv[11]] - else: - return [] -class FakeResponse: - def __init__(self, argv): - self.argv = argv - def info(self): - return FakeHeaders(self.argv) +import StringIO, cookielib, os, sys, urllib2 if __name__ == '__main__': + action = sys.argv[8] + uri = urllib2.urlparse.ParseResult( + scheme=sys.argv[9], + netloc=sys.argv[10], + path=sys.argv[11], + params='', + query='', + fragment='').geturl() + set_cookie = sys.argv[12] if len(sys.argv)>12 else None + if 'XDG_DATA_HOME' in os.environ.keys() and os.environ['XDG_DATA_HOME']: - jar = cookielib.MozillaCookieJar( - os.path.join(os.environ['XDG_DATA_HOME'],'uzbl/cookies.txt')) + f = os.path.join(os.environ['XDG_DATA_HOME'],'uzbl/cookies.txt') else: - jar = cookielib.MozillaCookieJar( - os.path.join(os.environ['HOME'],'.local/share/uzbl/cookies.txt')) + f = os.path.join(os.environ['HOME'],'.local/share/uzbl/cookies.txt') + jar = cookielib.MozillaCookieJar(f) + try: - jar.load() + jar.load(ignore_discard=True) except: pass - req = FakeRequest(sys.argv) - - action = sys.argv[8] + req = urllib2.Request(uri) if action == 'GET': jar.add_cookie_header(req) - if req.cookies: - print req.cookies + if req.has_header('Cookie'): + print req.get_header('Cookie') elif action == 'PUT': - res = FakeResponse(sys.argv) + hdr = urllib2.httplib.HTTPMessage(StringIO.StringIO('Set-Cookie: %s' % set_cookie)) + res = urllib2.addinfourl(StringIO.StringIO(), hdr, req.get_full_url()) jar.extract_cookies(res,req) - jar.save(ignore_discard=True) # save session cookies too - #jar.save() # save everything but session cookies + jar.save(ignore_discard=True) diff --git a/examples/data/uzbl/scripts/cookies.sh b/examples/data/uzbl/scripts/cookies.sh index 56b9c79..4398a03 100755 --- a/examples/data/uzbl/scripts/cookies.sh +++ b/examples/data/uzbl/scripts/cookies.sh @@ -48,6 +48,7 @@ which zenity &>/dev/null || exit 2 # uri=${uri/http:\/\/} # strip 'http://' part # host=${uri/\/*/} action=$8 # GET/PUT +shift host=$9 shift path=$9 @@ -2451,7 +2451,7 @@ static void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer use soup_message_add_header_handler(msg, "got-headers", "Set-Cookie", G_CALLBACK(save_cookies), NULL); GString *s = g_string_new (""); SoupURI * soup_uri = soup_message_get_uri(msg); - g_string_printf(s, "GET '%s' '%s'", soup_uri->host, soup_uri->path); + g_string_printf(s, "GET '%s' '%s' '%s'", soup_uri->scheme, soup_uri->host, soup_uri->path); run_handler(uzbl.behave.cookie_handler, s->str); if(uzbl.comm.sync_stdout && strcmp (uzbl.comm.sync_stdout, "") != 0) { @@ -2474,7 +2474,7 @@ save_cookies (SoupMessage *msg, gpointer user_data){ cookie = soup_cookie_to_set_cookie_header(ck->data); SoupURI * soup_uri = soup_message_get_uri(msg); GString *s = g_string_new (""); - g_string_printf(s, "PUT '%s' '%s' '%s'", soup_uri->host, soup_uri->path, cookie); + g_string_printf(s, "PUT '%s' '%s' '%s' '%s'", soup_uri->scheme, soup_uri->host, soup_uri->path, cookie); run_handler(uzbl.behave.cookie_handler, s->str); g_free (cookie); g_string_free(s, TRUE); |