Edit report at https://bugs.php.net/bug.php?id=61354&edit=1

 ID:                 61354
 Comment by:         goodwaiter at gmail dot com
 Reported by:        hufeng1987 at gmail dot com
 Summary:            htmlentities and htmlspecialchars doesn't respect
                     the default_charset
 Status:             Not a bug
 Type:               Bug
 Package:            Strings related
 Operating System:   Linux/Windows/
 PHP Version:        5.4.0
 Block user comment: N
 Private report:     N

 New Comment:

the post above is wrong,change from "Non Thread Safe" to "Thread Safe" cant fix 
it.

right fix way:
so guys above can change to windows + iis + isapi module + php, or windows + 
Apache + fastcgi/isapi module + php, can fix this bug.

I just test, only windows + iis + fastcgi + php will show the bug.
in isapi module or windows + Apache + fastcgi + php works fine.

and I test that,the bug maybe because of iis fastcgi.
in this case, Zend Multibyte Support allways be "provided by mbstring", even if 
I change zend.multibyte to off or on, it still "provided by mbstring".
in phpinfo() show below:

mbstring
Multibyte Support  enabled  
Multibyte string engine  libmbfl  
HTTP input encoding translation  disabled  
libmbfl version  1.3.2  

mbstring extension makes use of "streamable kanji code filter and converter", 
which is distributed under the GNU Lesser General Public License version 2.1. 

Multibyte (japanese) regex support  enabled  
Multibyte regex (oniguruma) version  4.7.1  

and I use this code to test on windows + iis6 + fastcgi + php:

echo(mb_internal_encoding());// show ISO-8859-1, right
$text = "我是测试";//use cp936 chinese chars
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "CP936";
$ary[] = "UTF-8";
echo mb_detect_encoding($text, $ary);//show cp936, right
mb_detect_order($ary);//set detect order
echo(htmlspecialchars($text));//show enmty, wrong !!!!!!!!!!!
echo mb_detect_encoding(htmlspecialchars($text), $ary);//show ASCII(not the guy 
think is utf8), wrong !!!!!!!!
echo(mb_internal_encoding());// show ISO-8859-1, not change, right

this test can show us that, all things goes right except htmlspecialchars(), 
where is the "ASCII" from? maybe iis6 + fastcgi cause this bug. but it's really 
a php bug.


Previous Comments:
------------------------------------------------------------------------
[2012-08-27 13:17:48] goodwaiter at gmail dot com

虽然更换到非线程安全版本能解决问题,但是难保下次版本,PHP不会把非线程安全版本的正常表现当作
BUG更新掉,所以我们要让PHP知道这确实是一个BUG。
BUG的中文表述很简单:
php.ini的Default 
encoding或者mb-internal-encoding的设置,对htmlspecialchars, 
htmlentities无效,这两个函数顽强的使用自己的utf-8,自以为是。
更流行的表述是:
htmlspecialchars, 
htmlentities独立使用自己的编码,这违反统一大局,PHP肯定不能容忍这样的存
在,必须要铲除这个BUG

------------------------------------------------------------------------
[2012-08-27 12:54:07] goodwaiter at gmail dot com

It's really a bug.
but we can fix this by a easy way(I'm use Windows):
just change you php from "Non Thread Safe" to "Thread Safe"
And everythings will be ok now.

------------------------------------------------------------------------
[2012-08-23 06:31:15] hufeng1987 at gmail dot com

though php 5.4.6 released, but these problem still exists.
do you really care the php developers?

------------------------------------------------------------------------
[2012-08-08 12:16:25] giodev at panozzo dot it

Yes, this is a HUGE problem for us also. We migrate a single server with a 
single homemade application and we lost 3-4 hours to fix all htmlspecialchars() 
and htmlentities() to force encoding back to ISO-8859-1.

And really, under these conditions we will never migrate other apps/servers to 
PHP 5.4. Too much work to be done not only by us, but also by external 
contractors and customer of hosting services.

It's a big cost both for us and for our customers.

------------------------------------------------------------------------
[2012-08-08 11:30:35] aheckmann at m-s dot de

We also have the problem with broken php code in 5.4.

It is really a huge amount of work, to switch old projects. 
We scanned our source files and found over 25.000 lines with 
htmlspecialchars(), not only written by us, also in many 3rd party libraries.

So we also can not switch these projects to php 5.4.

A solution to set the default encoding vi php.ini/ini_set() back to iso8859-1 
would be great.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=61354


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61354&edit=1

Reply via email to