From 43d999cc7c7edc54e3df7482b3ab3607755e4b6d 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. Signed-off-by: Theodoros Theodoropoulos Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- members/discharge.pl | 4 +++- opac/opac-discharge.pl | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/members/discharge.pl b/members/discharge.pl index db74cfcd1c..9e530bfcc1 100755 --- a/members/discharge.pl +++ b/members/discharge.pl @@ -90,11 +90,13 @@ if ( $input->param('discharge') and $can_be_discharged ) { 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; } } 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.39.5