最近鳥事很多,加上放假都去看車,所以沒有更新Blog。(對,我懶:P)
OpenWebMail自從2.53版後UTF-8做得相當好,但是在IE卻會發生中文檔名附件無法下載;用Big5介面則無此問題,但這樣實在太鳥了,尤其是敝公司有幾位員工名字有unicode字元,這樣就不能正常顯示,決定動手去硬改完全不懂的Openwebmail Perl程式碼。
把openwebmail-viewatt.pl改掉,在269列前,加上
由於小弟手賤,把所有員工的openwebmailrc都改成utf-8,就不管以上hack在big5是否正常了:P (會變亂碼,但仍然可以下載...)
Update :做成patch file,如下:
OpenWebMail自從2.53版後UTF-8做得相當好,但是在IE卻會發生中文檔名附件無法下載;用Big5介面則無此問題,但這樣實在太鳥了,尤其是敝公司有幾位員工名字有unicode字元,這樣就不能正常顯示,決定動手去硬改完全不懂的Openwebmail Perl程式碼。
把openwebmail-viewatt.pl改掉,在269列前,加上
} elsif ( $ENV{'HTTP_USER_AGENT'}=~/MSIE/ or $ENV{'HTTP_USER_AGENT'}=~/Chrome/ ) {
my $filename_encoded = uri_escape($filename);
$attheader.=qq|Content-Disposition: attachment; filename="$filename_encoded"\n|;
最前面也要加上use URI::Escape;
由於小弟手賤,把所有員工的openwebmailrc都改成utf-8,就不管以上hack在big5是否正常了:P (會變亂碼,但仍然可以下載...)
Update :做成patch file,如下:
--- openwebmail-viewatt.pl 2009-01-06 16:48:24.000000000 +0800
+++ /usr/local/www/cgi-bin/openwebmail/openwebmail-viewatt.pl 2009-01-06 16:14:24.000000000 +0800
@@ -4,6 +4,8 @@
#
use vars qw($SCRIPT_DIR);
+use URI::Escape;
+
if ( $0 =~ m!^(\S*)/[\w\d\-\.]+\.pl! ) { local $1; $SCRIPT_DIR=$1 }
if ($SCRIPT_DIR eq '' && open(F, '/etc/openwebmail_path.conf')) {
$_=; close(F); if ( $_=~/^(\S*)/) { local $1; $SCRIPT_DIR=$1 }
@@ -161,9 +163,13 @@
if ( $ENV{'HTTP_USER_AGENT'}=~/MSIE 5.5/ ) { # ie5.5 is broken with content-disposition: attachment
$attheader.=qq|Content-Disposition: filename="$subject.msg"\n|;
} else {
+# } elsif ( $ENV{'HTTP_USER_AGENT'}=~/MSIE 7.0/ ) { # ie7.0 is broken with content-disposition: attachment
+# $attheader.=qq|Content-Disposition: filename="aaa.msg"\n|;
+# } else {
$attheader.=qq|Content-Disposition: attachment; filename="$subject.msg"\n|;
}
+
# allow cache for msg in folder other than saved-drafts
if ($folder ne 'saved-drafts') {
$attheader.=qq|Expires: |.CGI::expires('+900s').qq|\n|.
@@ -266,6 +272,10 @@
# disposition:attachment default to save
if ( $ENV{'HTTP_USER_AGENT'}=~/MSIE 5.5/ ) { # ie5.5 is broken with content-disposition: attachment
$attheader.=qq|Content-Disposition: filename="$filename"\n|;
+# } else {
+ } elsif ( $ENV{'HTTP_USER_AGENT'}=~/MSIE/ or $ENV{'HTTP_USER_AGENT'}=~/Chrome/ ) { # ie7.0 is broken with utf-8
+ my $filename_encoded = uri_escape($filename);
+ $attheader.=qq|Content-Disposition: attachment; filename="$filename_encoded"\n|;
} else {
$attheader.=qq|Content-Disposition: attachment; filename="$filename"\n|;
}
留言
不過您大概打太快了,
語法裏有小小的錯誤。
^_________^
} elsif ( $ENV{'HTTP_USER_AGENT'}=~/MSIE/ or $ENV{'HTTP_USER_AGENT'}=~/Chrome/ ) {
my $filename_encoded = uri_escape($filename);
$attheader.=qq|Content-Disposition: attachment; filename="$filename_encoded"\n|;
光仔具有肉眼debug的能力,實在是高手呀!(或者該說人腦compiler呢?)