歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 19, 2024, 11:29:00 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  核心補強  |  修正 LifeType 1.2 在編輯文章時無法正確處理 & 字元的問題 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: 修正 LifeType 1.2 在編輯文章時無法正確處理 & 字元的問題  (閱讀 9241 次)
twu2
初級會員
**
文章: 61



檢視個人資料 個人網站
« 於: 三月 25, 2007, 08:02:18 下午 »

今天在修改文章時, 突然發現原本文章內的一些 html code 的內容, 在進入 TinyMCE 時, 就真的變成 html 的一部份, 而不是原本的原始碼內容. 原本以為是 TinyMCE 的問題, 特地換成 1.1.6 時使用的版本, 結果一樣. 所以特地再裝了一份 LifeType 1.1.6 版來測試, 發現在舊的版本是正常的, 而新的版本是不正常的. 看來是在 1.2 的處理上頭有了問題.

接著把 TinyMCE 的功能關閉, 使用內建的 html 編輯器, 然後比對了一下在 1.1.6 與 1.2 之間, 所產生的 html code 的差異, 果然發現在 1.2 之前的版本, 會把文章內容的 & 轉成 &amp; 然後再送出, 而 1.2 版並沒有這樣子處理, 所以後來的 TinyMCE 就直接把 &lt; 之類的碼, 直接轉成 < 之類的字元, 接著... 存回去時, 資料當然就與原本的內容有所不同了.

這個 patch 可以修正這個問題:
程式碼:
--- lifetype-1.2/class/view/admin/admineditpostview.class.php	2007-03-20 20:40:22.000000000 +0800
+++ blog/class/view/admin/admineditpostview.class.php 2007-03-25 20:21:39.027573368 +0800
@@ -50,7 +50,7 @@
             
              // set information about the post itself into the view
              $this->setValue( "postTopic", $this->_article->getTopic());
-                $this->setValue( "postText", $this->_article->getText( false ));
+                $this->setValue( "postText", str_replace('&', '&amp;', $this->_article->getText( false )));
              $this->setValue( "postSlug", $this->_article->getPostSlug());
              $this->setValue( "postId", $this->_article->getId());
              if( $this->_article->getCommentsEnabled())

patch 可以由這兒抓取: http://www.teatime.com.tw/~tommy/mypatch/lifetype_1.2_edit_and_problem.patch 

經過這樣子的修正之後, 目前看起來運作是正常的了.

本文同步發表於 http://blog.teatime.com.tw/1/post/215
修正也送到 mantis: http://bugs.lifetype.net/view.php?id=1235
« 最後編輯時間: 三月 25, 2007, 08:57:37 下午 由 twu2 » 已記錄

panying
新手見習
*
文章: 39


檢視個人資料
« 回覆文章 #1 於: 四月 07, 2007, 12:48:35 上午 »

這屬于比較嚴重的安全問題哦  吐舌頭
已記錄

頁: [1]
LifeType 中文開發論壇  |  開發  |  核心補強  |  修正 LifeType 1.2 在編輯文章時無法正確處理 & 字元的問題 « 上篇主題 下篇主題 »
    前往: