storing cookies now works with handler
authorDieter Plaetinck <dieter@plaetinck.be>
Wed, 6 May 2009 20:41:14 +0000 (22:41 +0200)
committerDieter Plaetinck <dieter@plaetinck.be>
Wed, 6 May 2009 20:41:14 +0000 (22:41 +0200)
README
TODO
examples/configs/sampleconfig
examples/configs/sampleconfig-dev
examples/scripts/cookies.sh

diff --git a/README b/README
index ad57566..104a958 100644 (file)
--- 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 (file)
--- a/TODO
+++ b/TODO
 * 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)
index 3a46142..4342389 100644 (file)
@@ -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
index b602c52..9ac8393 100644 (file)
@@ -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
index 69b786f..55498a1 100755 (executable)
@@ -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