changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > werc / changeset: Fix cookie parsing if more than one cookie present, add optional user/loggin-info sidebar

changeset 328: 6cc3ea4c97b3
parent 327: b57d9377edf9
child 329: 9fcf0fadc14b
author: uriel@engel.se.cat-v.org
date: Sat, 17 Jan 2009 03:43:05 +0100
files: bin/cgilib.rc
description: Fix cookie parsing if more than one cookie present, add optional user/loggin-info sidebar
     1.1--- a/bin/cgilib.rc	Sat Jan 17 03:05:19 2009 +0100
     1.2+++ b/bin/cgilib.rc	Sat Jan 17 03:43:05 2009 +0100
     1.3@@ -136,12 +136,9 @@
     1.4 fn get_cookie {
     1.5     ifs=';' { co = `{ echo $HTTP_COOKIE } }
     1.6 
     1.7-    #for(c in $co)
     1.8-    #    if(~ $c $1^'='*)  # This matching doesn't work
     1.9-    #        echo $c|sed 's/[^=]*=//' 
    1.10-
    1.11-    # WARNING: we might be adding a trailing new line
    1.12-    { for(c in $co) echo $c } | sed -n 's/[^=]*=//p' 
    1.13+    # XXX: we might be adding a trailing new line?
    1.14+    # The ' ?' is needed to deal with '; ' inter-cookie delimiter
    1.15+    { for(c in $co) echo $c } | sed -n 's/^ ?'$1'=//p' 
    1.16 }
    1.17 
    1.18 fn select_mime {
    1.19@@ -189,7 +186,7 @@
    1.20 # Check loggin status, if called with group arg we check membership too
    1.21 fn check_user {
    1.22     if(! get_user)
    1.23-        status='Not logged in'
    1.24+        status='Not logged in:' $status
    1.25     if not if(~ $#1 1 && ! grep -s '^'^$logged_user^'$' etc/groups/$1)
    1.26         status=User $logged_user not in group $1
    1.27     if not
    1.28@@ -240,6 +237,11 @@
    1.29     }
    1.30 }
    1.31 
    1.32+fn user_controls {
    1.33+    echo User: $"logged_user
    1.34+}
    1.35+
    1.36+
    1.37 # .md '(meta-)data' extract
    1.38 fn get_md_file_attr {
    1.39     sed -n '/^\* '$2': /p; /^\* '$2': /q; /^$/q' < $1