FCKeditor (後更名為 CKEditor) 2.6 版雖已老舊,但許多存續專案仍在使用。本文提供從下載、精簡檔案、ASP.NET 整合、上傳配置、安全性強化的完整部署指南。
FCKeditor_2.6.zip (SourceForge)MyWebApp/ ├── fckeditor/ # 整個精簡後的資料夾 │ ├── editor/ │ ├── fckconfig.js │ └── ...
方式 A:原生 JavaScript 整合 (無需 DLL)
方式 B:使用 FredCK.FCKeditorV2.dll 伺服器控制項 (舊版專案常用)
// 語言
FCKConfig.AutoDetectLanguage = true;
FCKConfig.DefaultLanguage = 'zh-tw'; // 或 zh-cn
// 工具列
FCKConfig.ToolbarSets["Default"] = [
['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
'/',
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['FitWindow','ShowBlocks','-','About']
];
// 上傳設定 (對應 connector 設定)
FCKConfig.LinkBrowser = true;
FCKConfig.ImageBrowser = true;
FCKConfig.FlashBrowser = true;
FCKConfig.LinkUpload = true;
FCKConfig.ImageUpload = true;
FCKConfig.FlashUpload = true;
// 絕對路徑輸出 (避免相對路徑在不同頁面層級失效)
FCKConfig.FullPage = false;
FCKConfig.UseBROnCarriageReturn = true; // Enter 產生
而非
<%@ Page Language="C#" %>
| 風險 | 對策 |
|---|---|
| 未授權上傳 | Connector `CheckAuthentication()` 嚴格驗證登入與角色 |
| 惡意腳本上傳 (.asp/.php/.exe) | `DeniedExtensions` 完整封鎖執行檔、腳本副檔名 |
| 雙重副檔名繞過 (shell.jpg.asp) | Connector 端驗證 `Path.GetExtension` 只取最後一段、檢查 MIME Type |
| 上傳目錄可執行腳本 | IIS 設定上傳資料夾 **移除執行權限** (Handler Mappings → 移除所有)、或放在 Web 根目錄外 |
| 大檔案阻塞服務 | `MaxFileSize` 限制、IIS `maxAllowedContentLength` 限制 |
| 路徑遍歷攻擊 (../../web.config) | Connector 內建防護,確認版本 ≥ 2.6.3 |
維護舊專案時,完成上述精簡部署與安全性配置可暫時降低風險;**規劃時程遷移至 CKEditor 4/5 或現代編輯器 (TipTap, Slate, Quill)** 為長遠之計。