2012-05-24 38 views
1
  

它似乎不像需要淨化的html代碼。htmlpurifier在用戶輸入 時返回問號?

爲什麼htmlpurifier會將該字符串變成問號,當它顯然應該是空格?

我確切的HTML代碼的淨化是:

//purify the html input 
include_once('inc/htmlpurifier-4.4.0/library/HTMLPurifier.auto.php'); 

$config = HTMLPurifier_Config::createDefault(); 
$config->set('Core.Encoding', 'UTF-8'); 
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); 

if (defined('PURIFIER_CACHE')) { 
    $config->set('Cache.SerializerPath', PURIFIER_CACHE); 
} else { 
    # Disable the cache entirely 
    $config->set('Cache.DefinitionImpl', null); 
} 

$input = $_POST["about_me"]; 

# Help out the Purifier a bit, until it develops this functionality 
while (($cleaner = preg_replace('!<(em|strong)>(\s*)</\1>!', '$2', $input)) != $input) { 
    $input = $cleaner; 
} 

$filter = new HTMLPurifier($config); 
$htmlpurified_output = $filter->purify($input); 

我已經在我的PHP頁面頁眉信息保存UTF8時啓用,也爲MySQL。

我能夠寫入,保存到數據庫,並在同一頁面上的其他textareas內重新顯示其他UTF8字符。罪魁禍首是htmlpurifier返回問號而不是實際的字符。

我會回答任何其他問題,我可以。

回答

2

答案是......

要始終確保您的編碼在所有區域中正確設置。

我有表中的「about_me」行只設置爲接受ascii字符。咄。

對不起浪費大家的時間。