Fix to always download altered file (no banner)

This commit is contained in:
iliajie
2023-05-22 12:07:37 +03:00
parent ee1c42960a
commit c4866735ba
2 changed files with 5 additions and 33 deletions

View File

@@ -307,7 +307,6 @@ ui_paging=Showing rows $1 to $2 of $3
ui_rowlabel=$2 in row $1 :
ui_filterbox=Type to filter..
ui_of=of
ui_jsblocked=JavaScript was removed to protect your privacy!
header_statusmsg=$1 logged into $2 $3 on $4 ($5)

View File

@@ -94,40 +94,13 @@ if ($ENV{'PATH_INFO'}) {
while(read(FILE, $buffer, $bsize)) {
if ($dangertypes) {
my $buffer_filtered = &filter_javascript($buffer, $pdftype);
# If content was changed upon filtering
# If content was changed upon
# filtering force download it
if ($buffer_filtered ne $buffer) {
# For text simply return filtered but
# tell user that it was filtered out
if ($htmltype) {
# Add a banner showing content was changed
my $prefdata =
&ui_alert_box($text{'ui_jsblocked'}, 'danger');
# Pass filtered content with the banner
# Insert the banner in HTML body
if ($buffer_filtered =~ s/(<body.*?>)/$1$prefdata/) {
$fdata = $buffer_filtered;
}
else {
# Insert the banner to the top of HTML doc
$fdata = "$prefdata$buffer_filtered";
}
# Update content length
$fsize = length($fdata);
}
# For no text files simply force
# download if file was altered
else {
# Force send it
$type = "application/octet-stream";
print "Content-Disposition: Attachment\n";
# Pass original content
$fdata = $buffer;
}
}
# Buffere was not changed, just pass it as is
else {
$fdata = $buffer;
$type = "application/octet-stream";
print "Content-Disposition: Attachment\n";
}
$fdata = $buffer;
}
else {
$fdata .= $buffer;