php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47130 JSON problems
Submitted: 2009-01-16 15:56 UTC Modified: 2009-01-20 12:09 UTC
From: svacinap at compsys dot cz Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.2.8 OS: Linux Slackware 12.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: svacinap at compsys dot cz
New email:
PHP Version: OS:

 

 [2009-01-16 15:56 UTC] svacinap at compsys dot cz
Description:
------------
Please read this: http://www.group-office.com/forum/viewtopic.php?f=1&t=4255&start=0

php log: 

[Fri Jan 16 10:26:34 2009] [error] [client 78.102.78.55] PHP Warning:  json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument in /var/www/mail/modules/email/json.php on line 1310



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-17 18:26 UTC] johannes@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.
 [2009-01-18 02:49 UTC] svacinap at compsys dot cz
Hi, thanks for interest :-) I am not a php programmer, so I don't know howto help any better, sorry. In the apache error log you can see this: /var/www/mail/modules/email/json.php on line 1310

so line 1310 is the last line of the json.php code, it's end like this: 

											
		}
	}
}catch(Exception $e)
{
	$response['feedback']=$e->getMessage();
	$response['success']=false;
}

if(defined('IMAP_CONNECTED'))
{
	$imap->close();
}

echo json_encode($response);

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

line 1310 is this: echo json_encode($response);

I don't really know If this is help to you. Please let my know, I will contact programmer of this code. 

Thanks
 [2009-01-18 15:37 UTC] scottmac@php.net
Any strings passed to json_encode should be valid utf-8, the manual 
and error message make this clear.
 [2009-01-19 13:54 UTC] svacinap at compsys dot cz
OK, but there were no problems with json_encode (the same script) in the php version 5.2.5 and 5.2.6 .. So I don't understant what is wrong. 

Here you have whole script: 

http://www.gmork.cz/files/json.php.txt
 [2009-01-19 16:00 UTC] scottmac@php.net
It didn't work before, it just silently cut the string in half and you never noticed it.

See bug #43941
 [2009-01-19 21:17 UTC] svacinap at compsys dot cz
OK. Group-office is the php web aplication .. 
I am IT administrator of the linux systems, NOT a programmer (my fault) ... 

OK. If I have Groupoffice3 and php 5.2.6 on my server, I can read the email messages, no problem, no errors : 

http://www.gmork.cz/files/oldphpworks.png

OK. If I have updated php to recent version 5.2.8, some of messages which have been made in the php aplication Groupoffice3 CAN NOT be read: 

http://www.gmork.cz/files/test-again.png

So php developer says: "This is php bug" , so php developers says "This is not bug". OKI. Sorry I don't know what to think, because I am not goddam programmer at all ... :-(
 [2009-01-19 21:24 UTC] svacinap at compsys dot cz
I meant: So Groupoffice3 developer says: "This is php bug"
 [2009-01-19 21:54 UTC] scottmac@php.net
The fact that it worked before was the bug. It's now doing what it 
should have done in the first place.
 [2009-01-20 00:04 UTC] svacinap at compsys dot cz
OK. Thanks for all the replies and your time. Thanks very much.
 [2009-01-20 11:38 UTC] svacinap at compsys dot cz
Developer of the Groupoffice3 is saying: 

How can I work around then when a string contains invalid UTF-8 data? Is 
there a function to strip invalid chars?

I wrote an e-mail client and with 5.2.6 it worked fine and now my app 
stops working when there is an invalid char in an incomming e-mail. I 
have no control of that of course so I need a function to make the data 
clean
 [2009-01-20 12:09 UTC] scottmac@php.net
It really depends on what the context is and this sort of thing should be asked on the users list.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC