|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: niazuddin dot ahmed at gmail dot com
New email:
PHP Version: OS:


 [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 Apr 22 21:01:28 2024 UTC