Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題
post by tommy @ 09 四月, 2007 11:40

在 LifeType 1.0.3 的時候, 我修正過一次 backslash 無法儲存的問題, 不過, 最近發現又有人反應這類的問題, 查了一下, 發現原本的修正, 在 magic_quotes_gpc 關閉時, 可以正確的儲存 backslash. 但是如果將 magic_quotes_gpc 打開之後, 就無法儲存 backslash 了.

下面這個 patch, 應該可以解決這一個問題了:

diff -Nur class.orig/data/kses.class.php class/data/kses.class.php
--- class.orig/data/kses.class.php 2007-03-20 20:40:22.000000000 +0800
+++ class/data/kses.class.php 2007-04-10 10:42:10.601863738 +0800
@@ -76,10 +76,13 @@
 
function Parse($string = "")
{
+/* we already handle magic_quotes_gpc in class/net/request.class.php
+ so don't do it again.
if (get_magic_quotes_gpc())
{
$string = stripslashes($string);
}
+*/

$string = $this->_no_null($string);
$string = $this->_js_entities($string);
$string = $this->_normalize_entities($string);
@@ -759,4 +762,4 @@
return '0.0.2 (OOP fork of kses 0.2.1)';
} # function _version
}
-?>
\ No newline at end of file
+?>
diff -Nur class.orig/database/db.class.php class/database/db.class.php
--- class.orig/database/db.class.php 2007-03-20 20:40:21.000000000 +0800
+++ class/database/db.class.php 2007-04-10 10:42:13.009975865 +0800
@@ -156,6 +156,8 @@
*/
function qstr($string) {
 
+/* we already handle magic_quotes_gpc in class/net/request.class.php
+ so don't do it again.
if (get_magic_quotes_gpc()) {
$string = stripslashes($string);
//$string = stripslashes($string);
@@ -163,6 +165,7 @@
$string = str_replace("\\'", "'", $string);
$string = str_replace('\\"', '"', $string);
}
+*/


$string = str_replace("\\", "\\\\", $string);
$string = str_replace("'", "''", $string);
@@ -170,4 +173,4 @@
return $string;
}
}
-?>
\ No newline at end of file
+?>

上面的 patch, 可以由這兒抓取: http://www.teatime.com.tw/~tommy/mypatch/lifetype_1.2_backslash.patch

Patch submit 到 Mantis: http://bugs.lifetype.net/view.php?id=1141  

Del.icio.us Furl HEMiDEMi Technorati MyShare
commons icon [1] Re:修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題 [ 回覆 ]

Tommy 您好,

我是攲器工作室的管理員~Simon Chaung。

最近在研究 Xoops 與 LifeType 整合的問題,在 Lifetype 的修正上,從您的網站文章上獲益良多。不知道我可不可以把您的網站加到我站上的「精選連結」裡分享給我的會員?

如果可以,您願意讓您的網誌在我的站上透過 RSS 聯播嗎?

commons icon [2] Re:修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題 [ 回覆 ]

可以, 沒有問題.

commons icon [3] Re:修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題 [ 回覆 ]

站長您好~
我照這個pitch改了
測試了一下
輸入\\n
在發佈完文章後,「重新再編輯文章」時
文章內容卻為\n
而非\\n

請問這個pitch有改到這個嗎???
我的magic_quotes_gpc有打開
--
Server : Ubuntu
Apache2: 2.2.3
PHP: 5.2.1

commons icon [4] Re:修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題 [ 回覆 ]

據說 1.2.x 目前的 trunk 版本已經修正這個問題了. 如果你一定要用 magic_quotes_gpc, 可以試試目前的 SVN 中的程式.

我是建議不要使用 magic_quotes_gpc (想不出有什麼理由一定要用這個), 就不會有問題了.

commons icon [5] Re:修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題 [ 回覆 ]

使用magic_quotes_gpc的目的,不就是為了避免類似SQL Injection這種問題嗎???
避免因為Server上的網頁安全性的code沒寫好,被入侵了,應該是這樣吧~這是我粗淺的認知XD

抱歉,我不清楚SVN要去哪抓比較方便@__@"

commons icon [6] Re:修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題 [ 回覆 ]

運氣好
終於被我找到bug了 :)
http://falldog.no-ip.org/lifetype/post/1/59

commons icon [7] Re:修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題 [ 回覆 ]

應該不會是你修正的那個地方. 至少在 magic_quotes_gpc 是關閉時, 沒有你的修正是正常的. (所以, 如果加上你的修正, 會變成不正常, 至少應該要檢查是否使用這功能.)

至於 magic_quotes_gpc 的問題. 我認為如果程式碼的寫法, 本身就沒考慮 SQL Injection 的問題, 需要用到 php 本身的設定去處理時. 我並不認為這個程式碼在其他地方的處理會去考慮到安全性的運作. 對於本身就會處理 quotes 的程式來說, 加上這個設定只是讓程式的處理更麻煩而已.

commons icon [8] Re:修正 LifeType 1.2 中, 打開 magic_quotes_gpc 後, 無法儲存 backslash [\] 字元的問題 [ 回覆 ]

你說的沒錯
我忘記加上magic_quote_gpc的判斷了!

迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

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