php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61396 illogical behavior of the function htmlspecialchars processing line
Submitted: 2012-03-15 05:27 UTC Modified: 2012-03-15 10:18 UTC
From: iblacksmoke at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.4.0 OS: doesn't matter
Private report: No CVE-ID: None
 [2012-03-15 05:27 UTC] iblacksmoke at gmail dot com
Description:
------------
Function htmlspecialchars does not have compatibility with all scripts in non-unicode charset, because it uses the default utf-8 encoding instead of the settings(php.ini). It's not a bug, but not quite logical behavior.

--------------
I'm sorry, I not have opportunity to create patch differences, because I do not have necessary software on my netbook. I hope, this guide will help you: http://pastebin.com/qCXNWxRh

Test script:
---------------
ini_set('default_charset','windows-1251');
echo htmlspecialchars('<h1>привет мир</h1>');

Expected result:
----------------
&lt;h1&gt;привет мир&lt;/h1&gt;

Actual result:
--------------
null string

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-15 05:40 UTC] iblacksmoke at gmail dot com
-Summary: this bug does not depend on operating system and other properties of environmen +Summary: illogical behavior of the function htmlspecialchars processing line
 [2012-03-15 05:40 UTC] iblacksmoke at gmail dot com
I know about the ability to specify the last parameter encoding, but I do not have the ability to change a lot of scripts already written.
 [2012-03-15 05:45 UTC] aharvey@php.net
-Status: Open +Status: Duplicate -Type: Feature/Change Request +Type: Bug -Package: Unicode Engine related +Package: Strings related
 [2012-03-15 05:45 UTC] aharvey@php.net
Duplicate of bug #61354.
 [2012-03-15 10:18 UTC] johannes@php.net
-Status: Duplicate +Status: Not a bug
 [2012-03-15 10:18 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Use the 3rd parameter of the function to use the encoding you want. everything else its likely to cause problems in the long run,for instance when mixing thirds party libs in.
 [2012-03-15 10:25 UTC] iblacksmoke at gmail dot com
>Use the 3rd parameter of the function to use the encoding you want.
>everything else its likely to cause problems in the long run,for instance when mixing thirds party libs in.
I not have ability to change all scripts on my server. This minor update is breaks compatibility.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 29 14:01:44 2020 UTC