Getting cookies can croak. Eval the fetching of cookies and do error handling. Fixes bug #11912.

This commit is contained in:
Colin Kuskie 2010-10-19 09:21:37 -07:00
parent b02aee50d8
commit aabb9ed214
3 changed files with 14 additions and 3 deletions

View file

@ -11,6 +11,7 @@
- fixed #11915: Date macro returns hour value w/ leading space
- fixed #11901: NotifyAboutVersionTag includes URL, even when inappropriate
- fixed #11902: forums bug
- fixed #11912: Corrupt cookie causes server 500 errors
7.10.2
- fixed #11884: Editing Templates impossible / Code editor not loaded

View file

@ -28,6 +28,7 @@ use Apache2::RequestUtil ();
use Apache2::ServerUtil ();
use APR::Request::Apache2;
use MIME::Base64 ();
use Scalar::Util qw/blessed/;
use WebGUI::Config;
use WebGUI::Pluggable;
use WebGUI::Session;
@ -94,7 +95,13 @@ sub authen {
}
$config ||= WebGUI::Config->new($server->dir_config('WebguiRoot'),$request->dir_config('WebguiConfig'));
my $cookies = APR::Request::Apache2->handle($request)->jar();
my $cookies = eval { APR::Request::Apache2->handle($request)->jar(); };
if (blessed $@ && $@->isa('APR::Request::Error')) {
$cookies = $@->jar;
}
else {
$cookies = {};
}
# determine session id
my $sessionId = $cookies->{$config->getCookieName};

View file

@ -17,7 +17,7 @@ package WebGUI::Session::Http;
use strict;
use WebGUI::Utility;
use Scalar::Util qw( weaken );
use Scalar::Util qw( weaken blessed );
=head1 NAME
@ -95,8 +95,11 @@ sub getCookies {
if ($self->session->request) {
# Have to require this instead of using it otherwise it causes problems for command-line scripts on some platforms (namely Windows)
require APR::Request::Apache2;
my $jarHashRef = APR::Request::Apache2->handle($self->session->request)->jar();
my $jarHashRef = eval { APR::Request::Apache2->handle($self->session->request)->jar(); };
return $jarHashRef if $jarHashRef;
if (blessed $@ and $@->isa('APR::Request::Error')) {
return $@->jar;
}
return {};
}
else {