openwebmail 2.53版 問題修正紀錄

雖然openwebmail 現有 Current Development Site 還在修正 Bugs
但是裝上去之後對中文字還是會有不太相容的問題…

所以只好一個一個解決現有的問題了

通訊錄亂碼:
這個部份可以參考我以前學校的師父的說明 http://phorum.study-area.org/index.php?topic=50495.0#msg275602
1. 編輯你的語系裡的 composemessage.template 檔

vi cgi-bin/openwebmail/etc/templates/zh_TW.Big5/composemessage.template

2. 找到下列的程式碼

url += "&to=" + escape (document.composeform.to.value);
url += "&cc=" + escape (document.composeform.cc.value);
url += "&bcc=" + escape (document.composeform.bcc.value);

3. 將上面這3行改成下面這樣

url += "&to=" + document.composeform.to.value;
url += "&cc=" + document.composeform.cc.value;
url += "&bcc=" + document.composeform.bcc.value;

所見即所得編輯器在IE6無法啟動:
2.53版使用的編輯器是HTMLArea 3.0 Beta
這版在IE6會無法啟動…
所以只要當內文是html格式..
會無法轉換,變成直接顯示html原始碼

google了一下…好像也沒有patch可以修正..
索性直接換掉這套古老的編輯器 …
Dev版是使用xinha…
在trace 後發現他改了太多架構…
so…就換成我習慣使用的FCKeditor
這套編輯器支援相當多常用的程式語言…
對瀏覽器的相容性也很高…
這次要使用js載入的方式來做

將下載完的檔案解壓縮後上傳到javascript/
設定fckconfig.js

再來就是要改 openwebmail-send.pl
找到 if ($_htmlarea_css_cache eq ") {
將以下程式刪除

if ($_htmlarea_css_cache eq '') {
  sysopen(F, "$config{'ow_htmldir'}/javascript/htmlarea.openwebmail/htmlarea.css", O_RDONLY) or
  openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_read'} $config{'ow_htmldir'}/javascript/htmlarea.openwebmail/htmlarea.css! ($!)");
  local $/; undef $/; $_htmlarea_css_cache=<F>; # read whole file in once
  close(F);
}

my $css = $_htmlarea_css_cache;
$css =~ s/\@\@\@BGCOLOR\@\@\@/$style{'window_light'}/g;
$css =~ s/"//g;

再將以下程式做替換

$html= qq|<script language="JavaScript" src="$config{'ow_htmlurl'}/javascript/htmlarea.openwebmail/htmlarea.js"></script>\n|.
qq|<script language="JavaScript" src="$config{'ow_htmlurl'}/javascript/htmlarea.openwebmail/dialog.js"></script>\n|.
qq|<script language="JavaScript" src="$config{'ow_htmlurl'}/javascript/htmlarea.openwebmail/popups/$htmlarealocale/htmlarea-lang.js"></script>\n|.
$html.
qq|<style type="text/css">\n$css\n</style>\n|.
qq|<script language="JavaScript">\n<!--\n|.
qq| var editor=new HTMLArea("body");\n|.
qq| editor.config.editorURL = "$config{'ow_htmlurl'}/javascript/htmlarea.openwebmail/";\n|.
qq| editor.config.imgURL = "images/";\n|.
qq| editor.config.popupURL = "popups/$htmlarealocale/";\n|.
qq| editor.config.bodyDirection = "$direction";\n|.
qq| editor.config.attlist = {\n$htmlarea_attlist_js};\n|.
qq| editor.config.attlist = {\n$htmlarea_attlist_js};\n|.
qq| editor.generate();\n|.
qq|//-->\n</script>\n|;

換成

$html= qq|<script language="JavaScript" src="$config{'ow_htmlurl'}/javascript/fckeditor/fckeditor.js"></script>\n|.
$html.
qq|<script language="JavaScript">\n<!--\n|.
qq| var editor=new FCKeditor("body");\n|.
qq| editor.BasePath = "$config{'ow_htmlurl'}/javascript/fckeditor/";\n|.
qq| editor.Height = "550";\n|.
qq| editor.ReplaceTextarea();\n|.
qq|//-->\n</script>\n|;

若想要讓chrome也可以使用html編輯器
找 sub htmlarea_compatible {
將以下程式替換

my $u=$ENV{'HTTP_USER_AGENT'};
if ( $u=~m!Mozilla/4.0! &&
  $u=~m!compatible;!) {
  return 0 if ($u=~m!Opera!);	# not Opera
  if ($u=~m!Windows! &&
  $u=~m!MSIE ([\d\.]+)! ) {
    return 1 if ($1>=5.5);	 # MSIE>=5.5 on windows platform
  }
}
if ( $u=~m!Mozilla/5.0! &&
  $u!~m!compatible;!) {
  if ($u!~m!(?:Phoenix|Galeon|Firebird)/! &&
    $u=~m!rv:([\d\.]+)! ) {
    return 1 if ($1 ge "1.3");	# full Mozilla>=1.3 on all plaform
  }
  if ($u=~m!Firebird/([\d\.]+)!) {
    return 1 if ($1 ge "0.6.1");	# Firebird>=0.6.1 on all plaform
  }
}
return 0;

替換成

return 1;

中文會有 [UTF-8?] 字樣:
這是針對使用Big5編碼的人…
若是使用UTF-8..則是會出現[BIG5?]

這個可以參考 http://www.to2100.idv.tw/?p=5358
但目前我還不打算改這部份…


發現問題出在shares/iconv.pl
找到

sub _iconv {

裡面的一個回傳值

return "[".uc($from)."?]".$s;

他的註解說如果轉換失敗,就會把來源編碼貼在字串的開頭…
只是…一般我們所看到的大部分文字都顯示正常…卻被貼上這個mark…
還不太瞭解他為何會是轉換失敗…

目前先把這串改成

return $s;

這樣就不會在出現那個討厭的mark….


另一個方法則是捨去_iconv這個function
採用Encode的方式來做
一樣是在iconv.pl

use Text::Iconv;

下方加入

use Encode qw/encode decode/;

找到

$text[$i]=~s/(\S+)/_iconv($from, $to, $1)/egis;

用下方程式取代

$text[$i]=~s/(\S+)/encode($to, decode($from, $1))/egis;

這樣也可以達到相同效果,
而且也可以大致上將編碼轉換過來,
轉不過來的字會變成?
至少…不會都是奇怪的方框了…

20100304
今天發現有人信箱會開不起來…
顯示Encode error….
因為他的信裡面有怪編碼….導致無法Encode…
所以只好改回上面的 return $s; 這個方法了

[相關文章]

  • No Related Post
  1. 2011 年 6 月 21 日