6.0.0-beta1
7/12/25

[#9529] json_encode(): Invalid UTF-8 sequence in argument
Summary json_encode(): Invalid UTF-8 sequence in argument
Queue Horde Framework Packages
Queue Version Git master
Type Bug
State Resolved
Priority 2. Medium
Owners slusarz (at) horde (dot) org
Requester rsalmon (at) mbpgroup (dot) com
Created 01/20/2011 (5287 days ago)
Due
Updated 02/21/2011 (5255 days ago)
Assigned 01/22/2011 (5285 days ago)
Resolved 01/25/2011 (5282 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
02/21/2011 08:44:17 AM rsalmon (at) mbpgroup (dot) com Comment #20 Reply to this comment

[Show Quoted Text - 13 lines]
Thank you for this intermediate solution.

02/21/2011 06:09:20 AM Michael Slusarz Comment #19
Taken from Horde DevelopersHorde Developers
Reply to this comment
Not much we can do about that message.  It is bad UTF-8 and 
json_encode() chokes on it.

Unfortunately, json_last_error() doesn't help out because of this 
issue: http://bugs.php.net/bug.php?id=54058

However, even in this case if json_last_error() worked properly, it 
doesn't solve because forcing a charset conversion to UTF-8 doesn't 
work either.

Solution: provide error message in preview pane with link to popup 
message (which is loaded via straight HTML so it is not subject to 
JSON encoding problems).
02/21/2011 05:53:18 AM Git Commit Comment #18 Reply to this comment
Changes have been made in Git for this ticket:

Bug #9529: On JSON encode error, print error message in preview pane

http://git.horde.org/horde-git/-/commit/9ff07c2c3faa2fe9a77e322c0294d1c38a871897
02/14/2011 05:35:22 PM rsalmon (at) mbpgroup (dot) com Comment #17
New Attachment: lex.eml Download
Reply to this comment
I ran into an other message with this issue.

it seams that json_encode doesn't like the chars right next to '45000 
ORLEANS (FRANCE)'

2011-02-14T18:26:26+01:00 DEBUG: HORDE [imp] PHP ERROR: json_encode(): 
Invalid UTF-8 sequence in argument [pid 8225 on line 252 of 
"/var/www/html/hordetest/libs/Horde/Serialize.php"]
2011-02-14T18:26:26+01:00 DEBUG: 1. Horde::sendHTTPResponse() 
/var/www/html/hordetest/services/ajax.php:73
2. Horde::escapeJson() /var/www/html/hordetest/libs/Horde.php:564
3. Horde_Serialize::serialize() /var/www/html/hordetest/libs/Horde.php:606
4. Horde_Serialize::_serialize() 
/var/www/html/hordetest/libs/Horde/Serialize.php:67
5. json_encode() /var/www/html/hordetest/libs/Horde/Serialize.php:252
6. Horde::errorHandler()

01/25/2011 05:05:21 PM Michael Slusarz Comment #16 Reply to this comment
typo ?
This is why you don't make changes at 2 in the morning :(
01/25/2011 05:04:50 PM Git Commit Comment #15 Reply to this comment
Changes have been made in Git for this ticket:

Bug #9529: fix decode() call

http://git.horde.org/horde-git/-/commit/fe1959fa39723feee2cb717d1dd422ff9445d1d8
01/25/2011 01:02:15 PM rsalmon (at) mbpgroup (dot) com Comment #14 Reply to this comment
Changes have been made in Git for this ticket:

Bug #9529: Fix undefined error

http://git.horde.org/horde-git/-/commit/c28f2bd6adf2be0645a80fdd5065e0402b1d7e51
typo ?
-             
$ob->setDescription(Horde_Mime::decode($data['description']), 'UTF-8');
+             
$ob->setDescription(Horde_Mime::decode($data['description'], 'UTF-8'));
01/25/2011 10:08:14 AM Git Commit Comment #13 Reply to this comment
Changes have been made in Git for this ticket:

Bug #9529: Fix undefined error

http://git.horde.org/horde-git/-/commit/c28f2bd6adf2be0645a80fdd5065e0402b1d7e51
01/25/2011 09:20:49 AM rsalmon (at) mbpgroup (dot) com Comment #12 Reply to this comment
2011-01-25T09:59:46+01:00 DEBUG: HORDE [imp] PHP ERROR: Missing 
argument 2 for Horde_Mime::decode(), called in 
/var/www/html/hordetest/libs/Horde/Mime/Part.php on line 1886 and 
defined [pid 31864 on line 298 of 
"/var/www/html/hordetest/libs/Horde/Mime.php"]
I only get those using traditional mode.
01/25/2011 09:07:32 AM rsalmon (at) mbpgroup (dot) com Comment #11 Reply to this comment
Changes have been made in Git for this ticket:

Bug #9529: Store description internally as UTF-8, not in charset of part

http://git.horde.org/horde-git/-/commit/929fe1215e12666b847e9fa865320e79bde0a923
The above patch fixed this issue, but now, (you've probably seen this 
by now) I get lots of theses :

2011-01-25T09:59:46+01:00 DEBUG: HORDE [imp] PHP ERROR: Missing 
argument 2 for Horde_Mime::decode(), called in 
/var/www/html/hordetest/libs/Horde/Mime/Part.php on line 1886 and 
defined [pid 31864 on line 298 of 
"/var/www/html/hordetest/libs/Horde/Mime.php"]

01/25/2011 12:57:35 AM Michael Slusarz Comment #10
State ⇒ Resolved
Priority ⇒ 2. Medium
Reply to this comment
Turns out it was an issue in horde/Mime instead - during the 
conversion of Horde code to the assumption that all data is internally 
stored in UTF-8, parsing the description field of a MIME header was 
not properly converted.  It was storing the header internally in the 
default charset of the part.
01/25/2011 12:55:35 AM Git Commit Comment #9 Reply to this comment
Changes have been made in Git for this ticket:

Bug #9529: Store description internally as UTF-8, not in charset of part

http://git.horde.org/horde-git/-/commit/929fe1215e12666b847e9fa865320e79bde0a923
01/24/2011 10:21:29 PM Michael Slusarz Comment #8 Reply to this comment
I click once on the message : I get the errors as described when 
creating this ticket. However, I can see the header (From, To, 
Date...) of the message, but not the body.

From there :
- if I doubled-click on the message, the message shows up just fine 
in the popup window.
- if I click reply, a reply window appear with the right content.
As mentioned previously, this is because these views are not using JSON data.
01/24/2011 10:20:29 PM Michael Slusarz Comment #7 Reply to this comment
Anyway, this is a Horde_Serialize issue, not an IMP issue.
I thought this was an IMP issue since the message is displayed using 
traditional view.
It's not displaying correctly because json_encode() is not encoding 
the string into valid UTF-8, so the in-browser decoding of the JSON 
response is failing.  This is why you can view the message fine if 
viewing in a popup window - since the message there is loaded directly 
in HTML rather than via AJAX/JSON.
01/24/2011 09:22:29 AM rsalmon (at) mbpgroup (dot) com Comment #6 Reply to this comment
using dynamic view,

I click once on the message : I get the errors as described when 
creating this ticket. However, I can see the header (From, To, 
Date...) of the message, but not the body.

From there :
- if I doubled-click on the message, the message shows up just fine in 
the popup window.
- if I click reply, a reply window appear with the right content.

01/24/2011 09:05:37 AM rsalmon (at) mbpgroup (dot) com Comment #5 Reply to this comment
Anyway, this is a Horde_Serialize issue, not an IMP issue.
I thought this was an IMP issue since the message is displayed using 
traditional view.

01/23/2011 04:27:44 AM Michael Slusarz Assigned to Horde DevelopersHorde Developers
Version ⇒ Git master
 
01/23/2011 04:27:30 AM Michael Slusarz Comment #4
Version ⇒
Queue ⇒ Horde Framework Packages
Reply to this comment
I can only partially confirm - I see the error in the browser, but I 
don't get any error message in the logs.

Anyway, this is a Horde_Serialize issue, not an IMP issue.
01/22/2011 05:24:59 PM Jan Schneider Comment #3
State ⇒ Assigned
Assigned to Michael Slusarz
Reply to this comment
Confirmed
01/20/2011 04:34:34 PM rsalmon (at) mbpgroup (dot) com Comment #2 Reply to this comment
using php-5.3.3, dynamic view ,the attched message does show.
I meant "the attched message does *not* show"

01/20/2011 04:33:29 PM rsalmon (at) mbpgroup (dot) com Comment #1
Priority ⇒ 1. Low
State ⇒ Unconfirmed
New Attachment: esp.eml Download
Patch ⇒ No
Milestone ⇒
Queue ⇒ IMP
Summary ⇒ json_encode(): Invalid UTF-8 sequence in argument
Type ⇒ Bug
Reply to this comment
using php-5.3.3, dynamic view ,the attched message does show.
I get the following errors with firebug and in horde.log :

doActionComplete
TypeError: id is null
  eval(r.js.join(';'));
dimpbase.js (ligne 1409)


2011-01-20T17:17:38+01:00 DEBUG: HORDE [imp] PHP ERROR: json_encode(): 
Invalid UTF-8 sequence in argument [pid 1743 on line 252 of 
"/var/www/html/hordetest/libs/Horde/Serialize.php"]
2011-01-20T17:17:38+01:00 DEBUG: 1. Horde::sendHTTPResponse() 
/var/www/html/hordetest/services/ajax.php:73
2. Horde::escapeJson() /var/www/html/hordetest/libs/Horde.php:564
3. Horde_Serialize::serialize() /var/www/html/hordetest/libs/Horde.php:606
4. Horde_Serialize::_serialize() 
/var/www/html/hordetest/libs/Horde/Serialize.php:67
5. json_encode() /var/www/html/hordetest/libs/Horde/Serialize.php:252
6. Horde::errorHandler()

although code in Serialize.php checks  for error 5, function 
json_last_error return 0.

I tried to check for error JSON_ERROR_UTF8 (available since PHP 5.3.3 
http://www.php.net/manual/en/function.json-last-error.php) without 
success.





Saved Queries