perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <do...@pobox.com>
Subject Re: Apache::Cookie bug
Date Wed, 01 Mar 2000 07:09:25 GMT
On Tue, 22 Feb 2000, Matt Sergeant wrote:

> If you set a cookie that is an arrayref, which is really a hashref, with
> undef in some of the values, you don't get those undef elements back:
> 
> Apache::Cookie->new(
> 	$r,
> 	-name => 'EXAMPLE',
> 	-value => {key1 => 'val', key2 => undef},
> 	-expires => '+6M',
> 	-path => '/',
> 	)->bake;
> 
> The cookie gets set properly to:
> 
> EXAMPLE=key1&val&key2&
> 
> but upon retrieval the array you get back is:
> 
> ('key1','val','key2')
> 
> rather than the correct:
> 
> ('key1', 'val', 'key2', undef)
> 
> Causing errors that say "Odd number of elements in hash assignment".

this should fix it (untested):

--- Cookie.xs   1999/06/29 01:49:16     1.2
+++ Cookie.xs   2000/03/01 07:12:45
@@ -75,7 +75,9 @@
                (void)hv_iterinit(hv); 
                while ((sv = hv_iternextsv(hv, &value, &len))) { 
                    (void)ApacheCookie_attr(RETVAL, key, value);
-                   (void)ApacheCookie_attr(RETVAL, key, SvPV(sv,na));
+                   (void)ApacheCookie_attr(RETVAL, key, 
+                                           sv == &sv_undef ? 
+                                           "" : SvPV(sv,na));
                }
            }
            else {



Mime
View raw message