首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> ASP.NET 基礎 >> 關於ASP.NET

FCKeditor 2.6 在 ASP.NET 中完整配置指南:精簡部署、語言包、上傳路徑與安全性設定

     編輯:關於ASP.NET

FCKeditor (後更名為 CKEditor) 2.6 版雖已老舊,但許多存續專案仍在使用。本文提供從下載、精簡檔案、ASP.NET 整合、上傳配置、安全性強化的完整部署指南。

1. 下載與精簡檔案 (減少部署體積)

  • 官方下載:FCKeditor_2.6.zip (SourceForge)
  • 解壓後 **刪除不必要檔案**:
    • 根目錄保留:`editor/`、`fckconfig.js`、`fckeditor.js`、`fckstyles.xml`、`fcktemplates.xml`
    • 刪除:`_samples/`、`_test/`、`_whatsnew.html`、`license.html` 等文檔
    • `editor/filemanager/connectors/` 僅保留 `aspx/` (ASP.NET 連接器),刪除 `php/`、`asp/`、`cfm/`、`jsp/`、`py/`、`lasso/`
    • `editor/lang/` 僅保留 `en.js`、`zh.js` (繁體)、`zh-cn.js` (簡體)
    • `editor/skins/` 僅保留使用的皮膚 (通常 `default/`、`office2003/`)
  • 精簡後約 **1.2 MB** (原 3.6 MB),加速部署與載入

2. ASP.NET 整合步驟

步驟 1:複製資料夾至專案

MyWebApp/
├── fckeditor/              # 整個精簡後的資料夾
│   ├── editor/
│   ├── fckconfig.js
│   └── ...

步驟 2:引用組件 (兩種方式)

方式 A:原生 JavaScript 整合 (無需 DLL)










方式 B:使用 FredCK.FCKeditorV2.dll 伺服器控制項 (舊版專案常用)

  1. 專案加入參考 `FredCK.FCKeditorV2.dll`
  2. 頁面註冊:`<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCK" %>`
  3. 使用控制項:
    
    
        

3. 關鍵配置:fckconfig.js


// 語言
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 產生 
而非

4. 上傳連接器配置:editor/filemanager/connectors/aspx/config.ascx


<%@ Page Language="C#" %>











 

5. 安全性強化清單 (必做)

風險對策
未授權上傳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

6. 遷移建議:升級至 CKEditor 4/5

  • FCKeditor 已停止維護,**安全風險高、不支援現代瀏覽器特性 (HTML5、Clipboard API 等)**
  • CKEditor 4:相容性佳、架構類似、遷移成本低
  • CKEditor 5:現代模組化架構、需重寫整合代碼、功能最強
  • 遷移步驟:替換前端 JS、更新工具列配置格式、調整 Connector API (CKEditor 使用不同參數名)

維護舊專案時,完成上述精簡部署與安全性配置可暫時降低風險;**規劃時程遷移至 CKEditor 4/5 或現代編輯器 (TipTap, Slate, Quill)** 為長遠之計。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved