See comments on bug 30261. > There is a fundamental flaw in output_error: > output_with_http_headers $query, $cookie, $template->output, 'html', > '404 Not Found'; > Although we pass $error, it always outputs a 404. I tried sending a 403, and > it does not work! > > The 404 from output_error is caught by Plack middleware and it will output > the 404 error document. In this case the OPAC 404 error document!
Created attachment 191332 [details] [review] Bug 30803: Don't hardcode 404 into output_error This patch removes the hardcoded "404 Not Found" status code and reason phrase from output_error and instead uses just the code passed into the function. Test Plan: 0. Apply patch and koha-plack --restart kohadev 1. Go to http://localhost:8080/cgi-bin/koha/tracklinks.pl?uri=https%3A%2F%2Ftest.com&biblionumber=29 2. Note normal OPAC 404 error Bonus points: 1. Change 404 to 403 in the first output_error in opac/tracklinks.pl 2. koha-plack --restart kohadev 3. Go to http://localhost:8080/cgi-bin/koha/tracklinks.pl?uri=https%3A%2F%2Ftest.com&biblionumber=29 4. Note normal OPAC 403 error
Adding a dependency on bug 41599 because this fix would break reports/acquisitions_stats.pl in an error condition it seems...
Actually, the thing with bug 41599 is a chicken and egg problem. It looks like "Possible SQL injection" will return a 200 error code which is fine for now. So may as well make bug 41599 depend on this one...
Created attachment 191339 [details] [review] Bug 30803: Don't hardcode 404 into output_error This patch removes the hardcoded "404 Not Found" status code and reason phrase from output_error and instead uses just the code passed into the function. Test Plan: 0. Apply patch and koha-plack --restart kohadev 1. Go to http://localhost:8080/cgi-bin/koha/tracklinks.pl?uri=https%3A%2F%2Ftest.com&biblionumber=29 2. Note normal OPAC 404 error Bonus points: 1. Change 404 to 403 in the first output_error in opac/tracklinks.pl 2. koha-plack --restart kohadev 3. Go to http://localhost:8080/cgi-bin/koha/tracklinks.pl?uri=https%3A%2F%2Ftest.com&biblionumber=29 4. Note normal OPAC 403 error Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 191340 [details] [review] Bug 30803: Add tests Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 191341 [details] [review] Bug 30803: Raise exception if $error is not passed Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Bug 41599 must be pushed along with this one.