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
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: 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
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC