Topic: no utf8 charset, php 5.2.13 breaks xajaxResponse

Hi all,
updated today php to version 5.2.13,
xajax 0.5 final
and now i have error
[Fri Mar 05 16:28:32 2010] [error] [client 127.0.0.1] PHP Warning:  htmlspecialchars() [<a href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid multibyte sequence in argument in xajax\\xajax_core\\xajaxResponse.inc.php on line 1709

in that line i have
  $bSpecialChars = (htmlspecialchars($sData, ENT_COMPAT, 'UTF-8') != $sData);

and in debug log it show

Fri Mar 05 2010 16:50:20 GMT+0200

ERROR: No response processor is available to process the response from the server.
Content-Type: text/html.
Check for error messages from the server.

Fri Mar 05 2010 16:50:20 GMT+0200

ERROR: The server returned the following HTTP status: 500
RECEIVED:

and now site wich used xajax not working, anyone can help me with this problem?
Thak you


P.S. and sorry for repost, cause first time im posted in thread with the same problem but in v.0.2 of xajax, and didnot saw this.

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

Can you post some code?

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

3 (edited by eliotik 2010-03-08 5:36:01 PM)

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

Hi, not today, at home, will post tomorrow,
code do next:
take some data from oracle base and put it to dbase tables. Data is in cyrilic(win-1251)
and i even dont know wich code to post cause code where this error pop is very big, if u want i can send u to email this function?

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

An email would be fine.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

Hi,

I have a similar error message:
PHP Warning:  htmlspecialchars() [<a href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid multibyte sequence in argument in /var/www/vhosts/xxxxx/httpdocs/fileadmin/oscommerce/catalog/xajax_core/xajaxResponse.inc.php on line 1575

That line used to read:
$bSpecialChars = (htmlspecialchars($sData, ENT_COMPAT, UTF-8) != $sData);

Following another topic (http://dev.xajaxproject.org/community// … hp?id=7136) I found I changed it to the following but that didn´t help:
$bSpecialChars = (htmlspecialchars($sData, ENT_COMPAT, XAJAX_DEFAULT_CHAR_ENCODING) != $sData);

PHP is 5.2.0 on Debian Etch


Lars

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

Hi Lars,

Boy did I ever drop the ball on this one! I believe eliotik sent me an email containing code back in March and it got lost in the works. My apologies.

I dug around and found the code and have been looking at it but haven't found anything obvious.

Lars, could you post the offending code?

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

Hi Ed,

how much code do you want? smile
Only the offending function or the whole file?

Lars

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

I think perhaps the whole file...

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

hm... so far I cannot see anything suspicious, but could you please paste the string causing the error? Guess the answer lies somewhere in the input of the function wink

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

A daring thesis ;-)

I´ve added debugging output to the file in question and now am waiting for some website user to stumble over the part that calls that function. Our developer testet some stuff in OsCommerce, but didn´t cause the error.

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

Here it is (part of it):
<a href="javascript:void(0)" onClick="xajax_sh
owArticles(52,'Gespr<E4>che',1,'2')"><div class="weinberater_right_item_text">Gespr<E4>che</div></a>

"Gespr<E4>che" should be "Gespräche".
All MySQL tables are set to UTF-8 collation.

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

I'm a bit confused, where does the conversion of the letter ä happen? that's not a proper encoding wink

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

No idea, perhaps from OsCommerce somewhere. I am going to discuss this with our developer next week.

Have a sunny weekend smile

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

Our developer has no clue. I don´t know if this will/can be investigated further... sad

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

I've seen some similar encoding this week at work, they were cause by json_encode() and UTF8-strings. Perhaps it help to track down the source of the malformed strings..

Re: no utf8 charset, php 5.2.13 breaks xajaxResponse

I know that's a old post but what I have found is:
My files have been saved on ISO-8859-1 charset, so I changed the following line:
$bSpecialChars = (htmlspecialchars($sData, ENT_COMPAT, 'UTF-8') != $sData);
to
$bSpecialChars = (htmlspecialchars($sData, ENT_COMPAT, 'ISO-8859-1') != $sData);

And it solved the warnings!