php.net |  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
Votes:1
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
 [2010-06-23 18:22 UTC] niazuddin dot ahmed at gmail dot com
Description:
------------
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:
----------------
{"test":"<b>Bold</b>"}

This is valid JSON as per http://www.jslint.com/

Actual result:
--------------
{"test":"<b>Bold&lt;\/b&gt;"}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-23 22:54 UTC] johannes@php.net
-Status: Open +Status: Feedback
 [2010-06-23 22:54 UTC] johannes@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

can't reproduce
 [2010-08-09 03:21 UTC] felipe@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-08-09 03:21 UTC] felipe@php.net
I got the expected result. Closed.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Oct 20 14:01:23 2020 UTC