aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
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 /examples
parent3f169ee1c2d71e827548cf8b3ed5e7013fc78294 (diff)
storing cookies now works with handler
Diffstat (limited to 'examples')
-rw-r--r--examples/configs/sampleconfig2
-rw-r--r--examples/configs/sampleconfig-dev2
-rwxr-xr-xexamples/scripts/cookies.sh27
3 files changed, 17 insertions, 14 deletions
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