note 68715 added to function.htmlentities

From: Date: Tue, 08 Aug 2006 15:44:46 +0000
Subject: note 68715 added to function.htmlentities
Groups: php.notes 
Request: Send a blank email to php-notes+get-115657@lists.php.net to get a copy of this message
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); } } ?> ---- Server IP: 194.153.94.10 Probable Submitter: 128.141.25.36 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.htmlentities.php Edit -- https://master.php.net/note/edit/68715 Del: integrated -- https://master.php.net/note/delete/68715/integrated Del: useless -- https://master.php.net/note/delete/68715/useless Del: bad code -- https://master.php.net/note/delete/68715/bad+code Del: spam -- https://master.php.net/note/delete/68715/spam Del: non-english -- https://master.php.net/note/delete/68715/non-english Del: in docs -- https://master.php.net/note/delete/68715/in+docs Del: other reasons-- https://master.php.net/note/delete/68715 Reject -- https://master.php.net/note/reject/68715 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115657) next »