ID: 43549 Updated by: [EMAIL PROTECTED] Reported By: mariusads at helpedia dot com -Status: Open +Status: Feedback Bug Type: Strings related Operating System: Redhat?, Linux PHP Version: 5.2.5 New Comment:
Works fine for me. Are you sure you have everything as utf-8..ie. the page you're sending the form from has content-type set to utf-8 ? Previous Comments: ------------------------------------------------------------------------ [2007-12-09 23:59:03] mariusads at helpedia dot com Description: ------------ I run a website that accepts game cheats submissions from users and displays them in categories and so on. User submits .txt files which are saved on the driver, a certain page on the website reads the text file or a fragment of it, performs htmlentities on it and displays it on the screen. Recently, the hosting company upgraded PHP to PHP 5.2.5 and with htmlentities returned an empty string when trying to escape it. I understand this is probably because of that fix regarding multi-byte characters in string, making htmlentities ignore input. That seems dumb a bit, shouldn't it return at least a string part that's before that multibyte character? Anyway, the file submitted is plain text and I honestly don't know what characters are wrong, that it would make htmlentities to ignore the text. The file is uploaded here: http://www.tgdb.net/a.txt In the scripts I have the following code: function htmlesc($text) { $s = html_entity_decode($text,ENT_QUOTES,'UTF-8'); return htmlentities($s,ENT_QUOTES,'UTF-8');} } The text passes html_entity_decode with no problems but htmlentities returns empty string. If possible, could you please tell me how could I check in the future if a string contains multibyte characters, so that i don't have this problem? Right now, the only solution the hosting company gave to me was to add a rule in .htaccess which makes the server process the PHP files with PHP4. Thank you for your help. Marius Hudea PS. The captcha doesn't seem to work right, I'm sure I didn't get the captcha wrong 8 times in a row Reproduce code: --------------- I've used the code below uploaded on several web servers to test: <html><body> <? $text = $_REQUEST['text']; echo htmlentities($text,ENT_QUOTES,'UTF-8'); ?> <form name="A" method="post"> <textarea name="text"></textarea> <input name="sub" type="submit" value="submit"/> </form> </body></html> Test file: http://www.tgdb.net/a.txt Expected result: ---------------- Expected to have the text displayed on the screen, to have the function return a non-empty string. Expected at least a partial string, up to that error, not having to check scripts for 5 minutes to see what went wrong. Actual result: -------------- Copy and paste text from a.txt results in an empty string. Any other text is processed correctly. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43549&edit=1
