Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

修正 LifeType 1.2 在編輯文章時無法正確處理 & 字元的問題
post by tommy @ 25 三月, 2007 20:50

今天在修改文章時, 突然發現原本文章內的一些 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  

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


2007/03/27: 

這個 patch 已經被收入 CVS 中了, 下一版的 LifeType 應該就會修正這個問題了.

Del.icio.us Furl HEMiDEMi Technorati MyShare
迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

Bad Behavior 已經阻擋了 62 個過去 7 天試圖闖關的垃圾迴響與引用。
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS