Apache::Cookie bug with value = undef
If I do this: Apache::Cookie-new( $r, -name = 'foo', -value = { will_break = '', completely_borked = 1 } )-bake; and then I later try to read the cookie in and do this: my %c = Apache::Cookie-fetch; my %cookie = $c{foo}-value; print $cookie{will_break}; It will print 'completely_borked'! The cookie's value looks something like this when sent to the browser: will_breakcompletely_borked1 The problem is here in apache_cookie.c while (*pair (val = ap_getword(r-pool, pair, ''))) { ap_unescape_url((char *)val); ApacheCookieAdd(c, val); } Here's a line from the ap_getword docs. Copies everything from line up to stop to a new string. line is updated to point to the first character after stop. Multiple occurrences of stop are skipped if present. It's that multiple occurrences are skipped bit that's causing the trouble. I tried to fix it but I am a C gimp and don't know WTF I am doing. -dave /*== www.urth.org We await the New Sun ==*/
Re: Apache::Cookie bug with value = undef
Hi Dave, On Mon, 8 Oct 2001, Dave Rolsky wrote: Apache::Cookie-new( $r, -name = 'foo', -value = { will_break = '', completely_borked = 1 } )-bake; Have you tried doing Apache::Cookie-new( $r, -name = 'foo', -value = { wont_break = '1', not_at_all_borked = '' } )-bake; instead? The problem is here in apache_cookie.c while (*pair (val = ap_getword(r-pool, pair, ''))) { Quite so. I tried to fix it but I am a C gimp and don't know WTF I am doing. Please don't modify the function ap_getword() in src/main/util.c as that will probably break all sorts of things. You could make a function like it by copying everything in the function API_EXPORT(char*) ap_getword() { ... ... while(*pos == stop) { ++pos; } ... ... } and making a new one for example API_EXPORT(char*) dave_ap_getword() { ... ... /* while(*pos == stop) { ++pos; } */ ... ... } and then call that instead. You will need to find the header file which declares the function and put a declaration along the same lines in there and then recompile. I'd leave this new function in the same file (util.c) for a quick hack but if you leave it like that then ten to one you'll forget it's in there and have to do it all over again next time you upgrade Apache. It's still better to find a way around the problem than to do something nasty like this. HTH, 73, Ged.
Re: Apache::Cookie bug with value = undef
On Mon, 8 Oct 2001, Ged Haywood wrote: Have you tried doing Apache::Cookie-new( $r, -name = 'foo', -value = { wont_break = '1', not_at_all_borked = '' } )-bake; instead? I can hardly control the order in which values are written out to the cookie via a hash! Unless instead of an anonymous hash, I passed in a reference to a tied hash or something. I tried to fix it but I am a C gimp and don't know WTF I am doing. Please don't modify the function ap_getword() in src/main/util.c as that will probably break all sorts of things. No, I was trying to fix it in apache_cookie.c It could simply check if the next char was '' before calling ap_getword. I'd leave this new function in the same file (util.c) for a quick hack but if you leave it like that then ten to one you'll forget it's in there and have to do it all over again next time you upgrade Apache. It's still better to find a way around the problem than to do something nasty like this. I was trying to patch Apache::Cookie, not Apache. Apache is doing what it says, and is therefore correct. Its simply not desirable to use that function in that particular place in the apache_cookie.c file. -dave /*== www.urth.org We await the New Sun ==*/