aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-05-06 22:41:14 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-05-06 22:41:14 +0200
commit130ce69dd0dda878f9186f98ab8a3e7f0f13b5a2 (patch)
treedb8648dff43edae633195c29e5669a4d9037e29f
parent3f169ee1c2d71e827548cf8b3ed5e7013fc78294 (diff)
storing cookies now works with handler
-rw-r--r--README1
-rw-r--r--TODO4
-rw-r--r--examples/configs/sampleconfig2
-rw-r--r--examples/configs/sampleconfig-dev2
-rwxr-xr-xexamples/scripts/cookies.sh27
5 files changed, 20 insertions, 16 deletions
diff --git a/README b/README
index ad57566..104a958 100644
--- a/README
+++ b/README
@@ -119,6 +119,7 @@ The script specific arguments are this:
$8 url of item to download
* cookie handler
$8 GET/PUT
+ $9 cookie (only with PUT requests)
KNOWN BUGS
- Segfaults when using zoom commands (happens when max zoom already reached?).
diff --git a/TODO b/TODO
index 73a8f21..642aa5a 100644
--- a/TODO
+++ b/TODO
@@ -32,13 +32,13 @@
* backspace key to pop characters from (multichar) command
* optional logging of http requests&responses with ip/hostname and port. -> how to implement? handler? stdout? (through a socket so you know what corresponds to what?)
* bench/optimize fifo vs socket performance. measure delays. minimize forks. does glib use a shell? how does it detect the shebang line?
-* cookie support.
+* cookie support. storing seems to work, but not yet sending
* "remember account settings" support. but how? configure post data per site? regex match eg '^bbs.archlinux.org' ?
* http_proxy env var not recognized. libproxy (used by libsoup) should handle this http://mail.gnome.org/archives/libsoup-list/2009-February/msg00018.html
* support ssl. do ssl certificate & exception management similar to how we do cookies
* improve DCOMMIT macro. what if WC is dirty? what if user downloaded tarball without .git?
* DARCH is not correct (should be at runtime)
-
+* when loading page foo.com, it can have img src=http://bar/..., uri in uzbl will be set to foo. we must pass bar to cookie handler
* variable replacing:
user agent -> str_replace(all vars) DONE
title bar -> str_replace(all vars)
diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig
index 3a46142..4342389 100644
--- a/examples/configs/sampleconfig
+++ b/examples/configs/sampleconfig
@@ -13,7 +13,7 @@
[behavior]
history_handler = /usr/share/uzbl/examples/scripts/history.sh
download_handler = /usr/share/uzbl/examples/scripts/download.sh
-cookie_handler = /usr/share/uzbl/examples/scripts/cookie.sh
+cookie_handler = /usr/share/uzbl/examples/scripts/cookies.sh
fifo_dir = /tmp
socket_dir = /tmp
always_insert_mode = 0
diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev
index b602c52..9ac8393 100644
--- a/examples/configs/sampleconfig-dev
+++ b/examples/configs/sampleconfig-dev
@@ -13,7 +13,7 @@
[behavior]
history_handler = ./examples/scripts/history.sh
download_handler = ./examples/scripts/download.sh
-cookie_handler = ./examples/scripts/cookie.sh
+cookie_handler = ./examples/scripts/cookies.sh
fifo_dir = /tmp
socket_dir = /tmp
always_insert_mode = 0
diff --git a/examples/scripts/cookies.sh b/examples/scripts/cookies.sh
index 69b786f..55498a1 100755
--- a/examples/scripts/cookies.sh
+++ b/examples/scripts/cookies.sh
@@ -5,6 +5,16 @@
# MAYBE TODO: allow user to edit cookie before saving. this cannot be done with zenity :(
# TODO: different cookie paths per config (eg per group of uzbl instances)
+# TODO: correct implementation.
+# see http://curl.haxx.se/rfc/cookie_spec.html
+# http://en.wikipedia.org/wiki/HTTP_cookie
+
+# TODO : check expires= before sending.
+# write sample script that cleans up cookies dir based on expires attribute.
+# TODO: check uri against domain attribute. and path also.
+# implement secure attribute.
+
+
if [ -f /usr/share/uzbl/examples/configs/cookies ]
then
file=/usr/share/uzbl/examples/configs/cookies
@@ -22,7 +32,9 @@ fi
which zenity &>/dev/null || exit 2
uri=$6
+uri=${uri/http:\/\/} # strip 'http://' part
action=$8 # GET/PUT
+cookie=$9
host=${uri/\/*/}
@@ -33,15 +45,6 @@ function match () {
sed -n "/$1/,/^\$/p" $file 2>/dev/null | grep -q "^$host"
}
-function readcookie () {
- cookie=
- while read
- do
- cookie="$REPLY
-"
- done
-}
-
function fetch_cookie () {
cookie=`cat $cookie_dir/$host.cookie`
}
@@ -52,11 +55,11 @@ function store_cookie () {
if match TRUSTED $host
then
- [ $action == PUT ] && readcookie && store_cookie $host
+ [ $action == PUT ] && store_cookie $host
[ $action == GET ] && fetch_cookie && echo "$cookie"
elif ! match DENY $host
then
- [ $action == PUT ] && readcookie && zenity --question --title 'Uzbl Cookie handler' --text "Accept cookie from $host ? Contents:\n$cookie" && store_cookie $host
- [ $action == GET ] && fetch_cookie && zenity --question --title 'Uzbl Cookie handler' --text "Submit cookie to $host ? Contents:\n$cookie" && echo $cookie
+ [ $action == PUT ] && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Accept this cookie from $host ?" --entry-text="$cookie"` && store_cookie $host
+ [ $action == GET ] && fetch_cookie && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Submit this cookie to $host ?" --entry-text="$cookie"` && echo $cookie
fi
exit 0