(context 'CGI) ; get cookies feature

Started by CaveGuy, June 18, 2007, 10:43:13 AM

Previous topic - Next topic

CaveGuy

The "get cookies" code that builds CGI:cookies from "HTTP_COOKIE" in cgi.lsp tears up cookies with embeded or tailing "=".



The following, fixed the problem, nicely for me.



(if (env "HTTP_COOKIE")

    (dolist (elmnt (parse (env "HTTP_COOKIE") ";"))

         (set 'var (trim (first (parse elmnt "="))))

 ### (set 'value (trim (last (parse elmnt "="))))

         (set 'value (slice elmnt (+ 1 (find "=" elmnt))))

         (push (list var value) cookies))

    (set 'cookies '()))



This feature plays hell with (base64-*) and (encrypt) of cookies !



I had been chaseing a random problem for weeks before I figured out how to reporduce it. In my case a (base64 string with a trailing "=" came back "" which trigered a differant, repeatable, error, that lead to this fix.

Well back to my rat killen, Just thought someone else might have a random cookie related problem that this might fix.
Bob the Caveguy aka Lord High Fixer.

Lutz

#1
Thanks for this fix, it will go into the next development version 9.1.9



Lutz

rickyboy

#2
Another tagline for newLISP: "newLISP: It's so easy, even a CaveGuy can do it."



(You might have to watch too much American TV to get this.  Sorry abroaders.)



Thanks for the fix Bob!
(λx. x x) (λx. x x)