(context 'CGI) ; get cookies feature

For the Compleat Fan
Locked
CaveGuy
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio
Contact:

(context 'CGI) ; get cookies feature

Post by 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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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

Lutz

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Post by rickyboy »

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)

Locked