Re: skip bad cookie value in Apache2::Cookie::Jar?
Mark Hedges <[email protected]> Tue, 21 Dec 2010 15:29:23 -0800 (PST)
| Newsgroups | gmane.comp.apache.apreq |
|---|---|
| Message-ID | <[email protected]> |
whoops forgot %attrs from @_... leave shifts
--- /usr/lib/perl5/Apache2/Cookie.pm.orig 2010-12-21 15:05:24.000000000 -0800
+++ /usr/lib/perl5/Apache2/Cookie.pm 2010-12-21 15:28:53.000000000 -0800
@@ -4,6 +4,7 @@
use APR::Request::Cookie;
use APR::Request::Apache2;
use APR::Request qw/encode decode/;
+use APR::Request::Error ();
use Apache2::RequestRec;
use Apache2::RequestUtil;
use overload '""' => sub { shift->as_string() }, fallback => 1;
@@ -102,7 +103,21 @@
sub new {
my $class = shift;
- my $jar = $class->APR::Request::Apache2::handle(shift);
+ my $r = shift;
+ my $jar;
+ eval { $jar = $class->APR::Request::Apache2::handle($r) };
+ if (my $err = $@) {
+ my $ref = ref $err;
+ if ( $ref eq 'APR::Request::Error'
+ && $err == APR::Request::Error::NOTOKEN
+ ) {
+ # skip bad cookies by getting jar from error
+ $jar = $err->jar;
+ }
+ else {
+ die $err; # rethrows any other APR::Error
+ }
+ }
my %attrs = @_;
while (my ($k, $v) = each %attrs) {
$k =~ s/^-//;