diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index f9a9cedfb..310235702 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -66,6 +66,9 @@ sub call { my $self = shift; my $env = shift; + ##Enable size limiting + $env->{'psgix.harakiri'} = 1; + my $session = $env->{'webgui.session'} or die 'Missing WebGUI Session - check WebGUI::Middleware::Session'; diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index 664ac0170..61bdb4a79 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -184,6 +184,7 @@ checkModule('Data::ICal', '0.16' ); checkModule('common::sense', '3.2' ); checkModule('Geo::Coder::Googlev3', '0.07' ); checkModule('IO::File::WithPath', ); +checkModule('Plack::Middleware::SizeLimit', ); failAndExit("Required modules are missing, running no more checks.") if $missingModule; diff --git a/share/site.psgi b/share/site.psgi index 85709bb60..b78533e7c 100644 --- a/share/site.psgi +++ b/share/site.psgi @@ -8,6 +8,13 @@ builder { my $config = $wg->config; my $streaming_uploads = $config->get('enableStreamingUploads'); # have to restart for changes to this to take effect + if (! $^O eq 'darwin') { + enable 'Plack::Middleware::SizeLimit' => ( + max_unshared_size => 200_000, + max_process_size => 500_000, + check_every_n_requests => 3, + ); + } enable 'Log4perl', category => $config->getFilename, conf => WebGUI::Paths->logConfig; enable 'SimpleContentFilter', filter => sub { if ( utf8::is_utf8($_) ) {