OTRS use encode UTF-8 in FileName but in IE this encode causes problems.
In OTRS version 2.4.7 this problem tried to solve but not definitively.
Problems of the decoding the filenames remained in package Filemanager and FAQ.
This packages used function Attachment in module Kernel::Output::HTML::Layout
In OTRS version 2.4.7 in this function added changes for decode filename attachment in some OTRS (exclude filename from header and include in url) but other package not support.
I offer more universal patch.
I used the object EncodeObject ($Self->{EncodeObject}) for forced decoding the filename in coding windows-1251.
Decoding is produced if it is used IE only.
diff:
Code: Select all
--- /opt/Paths/ORIGIN/Layout.pm 2010-02-06 09:42:17.000000000 +1000
+++ /opt/otrs/Kernel/Output/HTML/Layout.pm 2010-07-07 17:04:53.000000000 +1100
@@ -3160,6 +3160,7 @@
}
# clean filename to get no problems with some browsers
+ my $ConvertName = "BagFileNameDecode";
if ( $Param{Filename} ) {
# detect if IE workaround is used (solution for IE problem with multi byte filename)
@@ -3178,7 +3179,18 @@
# only deliver filename if needed
if ($FilenameInHeader) {
- $Output .= " filename=\"$Param{Filename}\"";
+ if ( $Self->{BrowserBreakDispositionHeader} ) {
+ $ConvertName = $Self->{EncodeObject}->Convert(
+ Text => $Param{Filename},
+ From => 'utf-8',
+ To => 'windows-1251',
+ Force => 1,
+ );
+ $Output .= " filename=\"<OTRS_FILE_NAME>\"";
+ }
+ else {
+ $Output .= " filename=\"$Param{Filename}\"";
+ }
}
}
$Output .= "\n";
@@ -3207,6 +3219,9 @@
# disable utf8 flag, to write binary to output
$Self->{EncodeObject}->EncodeOutput( \$Output );
+ if ( $Self->{BrowserBreakDispositionHeader} ) {
+ $Output =~ s/<OTRS_FILE_NAME>/$ConvertName/gi;
+ }
$Self->{EncodeObject}->EncodeOutput( \$Param{Content} );
# fix for firefox HEAD problem
Code: Select all
# clean filename to get no problems with some browsers
my $ConvertName = "BagFileNameDecode";
if ( $Param{Filename} ) {
# detect if IE workaround is used (solution for IE problem with multi byte filename)
# to solve this kind of problems use the following in dtl for attachment downloads:
# <a href="$Env{"CGIHandle"}/$LQData{"Filename"}?Action=...">xxx</a>
my $FilenameInHeader = 1;
# check if browser is broken
# if ( $Self->{BrowserBreakDispositionHeader} && $ENV{REQUEST_URI} ) {
# check if IE workaround is used
# if ( $ENV{REQUEST_URI} =~ /\Q$Self->{CGIHandle}\E\/.+?\?Action=/ ) {
# $FilenameInHeader = 0;
# }
# }
# only deliver filename if needed
# if ($FilenameInHeader) {
if ( $Self->{BrowserBreakDispositionHeader} ) {
$ConvertName = $Self->{EncodeObject}->Convert(
Text => $Param{Filename},
From => 'utf-8',
To => 'windows-1251',
Force => 1,
);
$Output .= " filename=\"<OTRS_FILE_NAME>\"";
}
else {
$Output .= " filename=\"$Param{Filename}\"";
}
# }
}
$Output .= "\n";
Code: Select all
# clean filename to get no problems with some browsers
my $ConvertName = "BagFileNameDecode";
if ( $Param{Filename} ) {
# check if browser is broken
if ( $Self->{BrowserBreakDispositionHeader} ) {
$ConvertName = $Self->{EncodeObject}->Convert(
Text => $Param{Filename},
From => 'utf-8',
To => 'windows-1251',
Force => 1,
);
$Output .= " filename=\"<OTRS_FILE_NAME>\"";
}
else {
$Output .= " filename=\"$Param{Filename}\"";
}
}
$Output .= "\n";
Code: Select all
# disable utf8 flag, to write binary to output
$Self->{EncodeObject}->EncodeOutput( \$Output );
if ( $Self->{BrowserBreakDispositionHeader} ) {
$Output =~ s/<OTRS_FILE_NAME>/$ConvertName/gi;
}
$Self->{EncodeObject}->EncodeOutput( \$Param{Content} );
I have tired patched after each upgrade OTRS.
Der patch arbaiten good!