Bug 42080: Invoice PDFs are forced downloads

Serve invoice files with a CSP header that prevents XSS
instead of with an attachment header that turns them into
downloads.

Testing plan:
- Set AcqEnableFiles preference to Do
- Acquisitions > Vendor > Receive Shipment > Create invoice
- Finish Receiving > Manage invoice files
- Upload an SVG with a <script> tag in it
- Click the SVG filename to open it
- Inspect browser's console: it should say something about a
script being blocked due to the CSP directive

Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Eric Phetteplace 2026-03-12 13:47:50 -07:00 committed by Pedro Amorim
parent a0136e5f2e
commit 0161a73d17
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 3 additions and 3 deletions

View File

@ -63,9 +63,9 @@ if ( $op eq 'download' ) {
my $fname = $file->{'file_name'};
my $ftype = $file->{'file_type'};
print $input->header(
-type => $file->{'file_type'},
-charset => 'utf-8',
-attachment => $file->{'file_name'}
-type => $file->{'file_type'},
-charset => 'utf-8',
'Content-Security-Policy' => "default-src 'none'; script-src 'none';"
);
print $file->{'file_content'};
} else {