ID:               47993
 User updated by:  mariusads at helpedia dot com
 Reported By:      mariusads at helpedia dot com
-Status:           No Feedback
+Status:           Open
 Bug Type:         Apache related
 Operating System: Windows 2003 Web Edition
 PHP Version:      5.2.9
 New Comment:

I've provided all the information I think it's needed so it shouldn't
be closed but investigated.


Previous Comments:
------------------------------------------------------------------------

[2009-04-24 01:00:01] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2009-04-17 21:56:03] mariusads at helpedia dot com

I've done further tests on the Apache 1.3.33 version.

With or without php.ini present in c:\windows the error is not
reported.
I've also tried with PHP 5.2.5 and it's also not reported, with or
without php.ini present.

i've added a trigger_error() call right above the calls to
htmlspecialchars or htmlentities and those notices appear in the PHP
error log but NOT in the apache error log (configuration option for a
virtualhost in httpd.conf).
The warnings for date function usage (when I enabled E_STRICT) appear
in both error logs.

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

[2009-04-17 21:36:39] mariusads at helpedia dot com

Yes, both servers have:

D:\php>php -v
PHP 5.2.9-2 (cli) (built: Apr  9 2009 08:23:19)

downloaded the same day from the php site.

php.ini derived from php.ini-recommended with minor changes such as
setting the smtp mail server.
I don't have any problems uploading the php.ini files somewhere if you
guys think it's needed.

Here are the phpinfo dumps, as much as I'm comfortable showing:

http://94.75.244.244/apache1.txt
http://94.75.244.244/apache2.txt

the only important diffs seem to be that i have mhash gettext and
mysqli enabled on the Apache 1.3.3 version. I tested with and without
gettext and the same, no warnings are shown on 1.3.33

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

[2009-04-16 19:30:55] [email protected]

Is the same php.ini used by both apache1 and 2? Are both running 
exactly same PHP version? (check all these from phpinfo() output from 
each server!)

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

[2009-04-16 18:46:35] mariusads at helpedia dot com

Description:
------------
PHP 5.2.9-2 (cli) (built: Apr  9 2009 08:23:19)

htmlspecialchars and htmlentities return empty strings when the text
passed to them is not correct in the format you tell it, this is known.

The problem I see is that the with an identical PHP.INI file, the
following warnings are showing in logs when used with Apache 2.0.63 but
don't appear when used with Apache 1.3.33 (and probably other 1.3.xx):

[Thu Apr 16 20:12:53 2009] [error] [client x.x.x.x] PHP Warning: 
htmlspecialchars() [<a
href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid
multibyte sequence in argument in D:\\website\\file.php on line 83

[Thu Apr 16 19:38:28 2009] [error] [client x.x.x.x] PHP Warning: 
htmlentities() [<a
href='function.htmlentities'>function.htmlentities</a>]: Invalid
multibyte sequence in argument in D:\\website\\file.php on line 83

These warnings appear on Apache 2.0.63, they don't appear on Apache
1.3.33

The INI is configured with error_reporting E_ALL (phpinfo shows
error_reporting => 6143 => 6143) and even with E_ALL|E_STRICT the Apache
1.3.33 version doesn't show the warnings but does show recommendations
about the date function and timezone settings so the error log clearly
works.


Reproduce code:
---------------
Download the following NFO file: http://www.tgdb.net/temp/test.nfo

Save it in the same folder where you'll run the following code:

<?php

$text = file_get_contents('test.nfo');

echo htmlspecialchars($text,ENT_QUOTES,'UTF-8');
echo htmlentities($text, ENT_QUOTES,'UTF-8');
echo 'Done';
?>

The NFO file above contains ASCII art done with characters with ascii
code above 0x7F so it's an invalid UTF-8, therefore the functions will
both fail returning an empty string. 

That's not the point here - though it's arguable if it's the best
solution instead of just ignoring bad unicode chars - please continue
reading

The problem is I want to receive a warning, so that I'll be able to use
error_get_last() and pass the text through a filter before trying to
echo it again. 

In my case it's not possible to pre-filter all nfo files because some
contain valid UTF-8 code and no ASCII art, others have only ASCII art.


Expected result:
----------------
I should see warning messages in the logs no matter the Apache version.

Actual result:
--------------
On Apache 1.3.33, no warnings are shown when htmlentities and
htmlspecialchars receive invalid text. 


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


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

Reply via email to