aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-05-12 22:44:53 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-05-12 22:44:53 +0200
commit8379e623c118f7861ee52884556a8b201b441dc9 (patch)
tree5621d4a3fa371861bc0deffc3c5cc0199e5076b4 /examples
parent8e7c17114da378018d6825d3212b901fa99078fc (diff)
2 bugfixes in cookie handler
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/scripts/cookies.sh23
1 files changed, 16 insertions, 7 deletions
diff --git a/examples/scripts/cookies.sh b/examples/scripts/cookies.sh
index 9f6d202..cd449dc 100755
--- a/examples/scripts/cookies.sh
+++ b/examples/scripts/cookies.sh
@@ -5,7 +5,7 @@
# kb.mozillazine.org FALSE / FALSE 1146030396 wikiUserID 16993
# domain alow-read-other-subdomains path http-required expiration name value
# you probably want your cookies config file in your $XDG_CONFIG_HOME ( eg $HOME/.config/uzbl/cookies)
-
+# Note. in uzbl there is no strict definition on what a session is. it's YOUR job to clear cookies marked as end_session if you want to keep cookies only valid during a "session"
# 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)
@@ -19,6 +19,7 @@
# implement secure attribute.
# support blocking or not for 3rd parties
# http://kb.mozillazine.org/Cookies.txt
+# don't always append cookies, sometimes we need to overwrite
if [ -f /usr/share/uzbl/examples/configs/cookies ]
then
@@ -60,13 +61,13 @@ function parse_cookie () {
do
if [ "$first_pair" == 1 ]
then
- field_name=${i%%=*}
- field_value=${i#*=}
+ field_name=${pair%%=*}
+ field_value=${pair#*=}
first_pair=0
else
read -r pair <<< "$pair" #strip leading/trailing wite space
- key=${i%%=*}
- val=${i#*=}
+ key=${pair%%=*}
+ val=${pair#*=}
[ "$key" == expires ] && field_exp=`date -u -d "$val" +'%s'`
# TODO: domain
[ "$key" == path ] && field_path=$val
@@ -78,8 +79,16 @@ function parse_cookie () {
# match cookies in cookies.txt againsh hostname and path
function get_cookie () {
path_esc=${path//\//\\/}
- cookie=`awk "/^[^\t]*$host\t[^\t]*\t$path_esc/" cookie_file 2>/dev/null | tail -n 1`
- [ -n "$cookie" ]
+ cookie=`awk "/^[^\t]*$host\t[^\t]*\t$path_esc/" $cookie_file 2>/dev/null | tail -n 1`
+ if [ -z "$cookie" ]
+ then
+ false
+ else
+ read domain alow_read_other_subdomains path http_required expiration name value <<< "$cookie"
+ cookie="$name=$value"
+ #echo "COOKIE $cookie" >> $HOME/cookielog
+ true
+ fi
}
[ $action == PUT ] && parse_cookie && echo -e "$field_domain\tFALSE\t$field_path\tFALSE\t$field_exp\t$field_name\t$field_value" >> $cookie_file