From e9a0fc2e48adcac5a676677f950292073fc87bc5 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 3 Oct 2019 09:34:17 +0200 Subject: [PATCH] Bug 23723: using exit inside eval to stop sending output to browser doesn't work under plack When fixing Bug 23589 Theodoros Theodoropoulos noticed that we are sending headers and html after pdf output to browser. Using exit inside eval block doesn't stop plack from generating headers and html page after exit since CGI::Compile will catch exit but doesn't stop emiting output. Example is: eval { warn "in eval"; exit; }; warn "after eval"; Under CGI, this would print just "in eval", but under plack we get both lines and thus generate additional header and html after we already sent pdf data. --- opac/opac-discharge.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opac/opac-discharge.pl b/opac/opac-discharge.pl index 4e8381bef8..75b6af8056 100755 --- a/opac/opac-discharge.pl +++ b/opac/opac-discharge.pl @@ -99,11 +99,13 @@ elsif ( $op eq 'get' ) { my @lines = <$fh>; close $fh; print @lines; - exit; }; if ( $@ ) { carp $@; $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] ); + } else { + # no error, pdf is sent, so stop sending data to browser + exit; } } else { -- 2.11.0