note 68715 deleted from function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:55:41 +0000 |
| Subject: | note 68715 deleted from function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154913@lists.php.net to get a copy of this message | ||
Note Submitter: lorenzo masetti at libero it
----
i think I found a bug in makeSafeEntities procedure. I don't know why but if the string has a
special charachter as the last one (e.g. 'liberté') the result will be truncated
('libert')
I solved by adding and taking a way a blank at the end of the string , it is not the most
elegant solution but it works
This is the part that I changed in the original code that is at http://www.prolifique.com/entities.php.txt
<?php
function makeSafeEntities($str, $convertTags = 0, $encoding = "") {
if (is_array($arrOutput = $str)) {
foreach (array_keys($arrOutput) as $key)
$arrOutput[$key] = makeSafeEntities($arrOutput[$key],$encoding);
return $arrOutput;
}
else if (!empty($str)) {
$str .= " ";
$str = makeUTF8($str,$encoding);
$str = mb_convert_encoding($str,"HTML-ENTITIES","UTF-8");
$str = makeAmpersandEntities($str);
if ($convertTags)
$str = makeTagEntities($str);
$str = correctIllegalEntities($str);
return substr($str, 0, strlen($str)-1);
}
}
?>