Author: joes
Date: Wed Aug 24 15:39:33 2005
New Revision: 239955
URL: http://svn.apache.org/viewcvs?rev=239955&view=rev
Log:
encode()/decode() were busted with zero-length args. This caused
Apache2::Cookie::new() to segfault on cookie value of "".
Modified:
httpd/apreq/trunk/CHANGES
httpd/apreq/trunk/glue/perl/t/apreq/cookie.t
httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm
httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs
Modified: httpd/apreq/trunk/CHANGES
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/CHANGES?rev=239955&r1=239954&r2=239955&view=diff
==============================================================================
--- httpd/apreq/trunk/CHANGES (original)
+++ httpd/apreq/trunk/CHANGES Wed Aug 24 15:39:33 2005
@@ -5,6 +5,10 @@
@section v2_07 Changes with libapreq2-2.07
+- Perl API [joes]
+ encode()/decode() were busted with zero-length args. This caused
+ Apache2::Cookie::new() to segfault on cookie value of "".
+
- C API [joes]
Add apreq_charset_divine() and eliminate charset offset from return
value of apreq_decode(v).
Modified: httpd/apreq/trunk/glue/perl/t/apreq/cookie.t
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/t/apreq/cookie.t?rev=239955&r1=239954&r2=239955&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/t/apreq/cookie.t (original)
+++ httpd/apreq/trunk/glue/perl/t/apreq/cookie.t Wed Aug 24 15:39:33 2005
@@ -6,7 +6,7 @@
use Apache::TestUtil;
use Apache::TestRequest qw(GET_BODY GET_HEAD);
-plan tests => 8, have_lwp;
+plan tests => 9, have_lwp;
require HTTP::Cookies;
@@ -14,15 +14,23 @@
{
my $test = 'new';
- my $value = 'bar';
+ my $value = 'new';
ok t_cmp(GET_BODY("$location?test=new"),
$value,
$test);
}
{
- # XXX why does this test fail?
+ my $test = '';
+ my $value = 'foo=; path=/quux; domain=example.com';
+ my ($header) = (GET_HEAD("$location?test=$test")
+ =~ /^#Set-Cookie:\s+(.+)/m) ;
+ ok t_cmp($header,
+ $value,
+ $test);
+}
+{
my $test = 'bake';
- my $value = 'foo=bar; path=/quux; domain=example.com';
+ my $value = 'foo=bake; path=/quux; domain=example.com';
my ($header) = (GET_HEAD("$location?test=bake")
=~ /^#Set-Cookie:\s+(.+)/m) ;
ok t_cmp($header,
@@ -31,7 +39,7 @@
}
{
my $test = 'new';
- my $value = 'bar';
+ my $value = 'new';
ok t_cmp(GET_BODY("$location?test=new;expires=%2B3M"),
$value,
$test);
Modified: httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm?rev=239955&r1=239954&r2=239955&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm (original)
+++ httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm Wed Aug 24
15:39:33 2005
@@ -33,16 +33,17 @@
@expires = ("expires", $req->APR::Request::args('expires'))
if $req->APR::Request::args('expires');
my $cookie = Apache2::Cookie->new($r, name => "foo",
- value => "bar",
+ value => $test,
domain => "example.com",
path => "/quux",
@expires);
- if ($test eq "bake") {
+
+ if ($test eq "bake" or $test eq "") {
$cookie->bake($req);
}
elsif ($test eq "bake2") {
- $cookie->set_attr(version => 1);
- $cookie->bake2;
+ $cookie->version(1);
+ $cookie->bake2($req);
}
$r->print($cookie->value);
}
Modified: httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs?rev=239955&r1=239954&r2=239955&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs Wed Aug 24
15:39:33 2005
@@ -8,7 +8,7 @@
char *src;
CODE:
src = SvPV(in, len);
- RETVAL = newSV(3 * len);
+ RETVAL = newSV(3 * len + 1);
SvCUR_set(RETVAL, apreq_encode(SvPVX(RETVAL), src, len));
SvPOK_on(RETVAL);
@@ -24,7 +24,7 @@
char *src;
CODE:
src = SvPV(in, len);
- RETVAL = newSV(len);
+ RETVAL = newSV(len + 1);
apreq_decode(SvPVX(RETVAL), &dlen, src, len); /*XXX needs error-handling */
SvCUR_set(RETVAL, dlen);
SvPOK_on(RETVAL);