|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52161 json_encode encoding HTML tags within strings incorrectly
Submitted: 2010-06-23 18:22 UTC Modified: 2010-08-09 03:21 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: niazuddin dot ahmed at gmail dot com Assigned: felipe (profile)
Status: Closed Package: JSON related
PHP Version: 5.3.2 OS: RedHat
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
49 - 44 = ?
Subscribe to this entry?

 [2010-06-23 18:22 UTC] niazuddin dot ahmed at gmail dot com
When using json_encode for strings with HTML tag, end tag gets HTML encoded but the start tag is left alone 

Test script:
echo json_encode(array('test' => '<b>Bold</b>'));

Expected result:

This is valid JSON as per

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-23 22:54 UTC]
-Status: Open +Status: Feedback
 [2010-06-23 22:54 UTC]
Please try using this snapshot:
For Windows:

can't reproduce
 [2010-08-09 03:21 UTC]
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-08-09 03:21 UTC]
I got the expected result. Closed.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 07:01:34 2024 UTC