From 6271d7a81a7865cfe849c5ce608b07ce813f35b3 Mon Sep 17 00:00:00 2001 From: uriel Date: Sat, 17 Jan 2009 03:43:05 +0100 Subject: [PATCH] Fix cookie parsing if more than one cookie present, add optional user/loggin-info sidebar --- bin/cgilib.rc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/cgilib.rc b/bin/cgilib.rc index 24e5a0a..5aa0c47 100644 --- a/bin/cgilib.rc +++ b/bin/cgilib.rc @@ -136,12 +136,9 @@ fn set_cookie { fn get_cookie { ifs=';' { co = `{ echo $HTTP_COOKIE } } - #for(c in $co) - # if(~ $c $1^'='*) # This matching doesn't work - # echo $c|sed 's/[^=]*=//' - - # WARNING: we might be adding a trailing new line - { for(c in $co) echo $c } | sed -n 's/[^=]*=//p' + # XXX: we might be adding a trailing new line? + # The ' ?' is needed to deal with '; ' inter-cookie delimiter + { for(c in $co) echo $c } | sed -n 's/^ ?'$1'=//p' } fn select_mime { @@ -189,7 +186,7 @@ fn login_user { # Check loggin status, if called with group arg we check membership too fn check_user { if(! get_user) - status='Not logged in' + status='Not logged in:' $status if not if(~ $#1 1 && ! grep -s '^'^$logged_user^'$' etc/groups/$1) status=User $logged_user not in group $1 if not @@ -240,6 +237,11 @@ fn auth_user { } } +fn user_controls { + echo User: $"logged_user +} + + # .md '(meta-)data' extract fn get_md_file_attr { sed -n '/^\* '$2': /p; /^\* '$2': /q; /^$/q' < $1