You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Doug MacEachern <do...@pobox.com> on 2000/03/01 08:09:25 UTC
Re: Apache::Cookie bug
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 {