php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70897 htmlspecialchars() add unnecessary characters.
Submitted: 2015-11-12 00:15 UTC Modified: 2015-11-22 04:22 UTC
From: reject5514 at naver dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.6.15 OS: Arch Linux ARM 4.1.12
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: reject5514 at naver dot com
New email:
PHP Version: OS:

 

 [2015-11-12 00:15 UTC] reject5514 at naver dot com
Description:
------------
---
From manual page: http://www.php.net/function.htmlspecialchars
---

htmlspecialchars function add unnessary characters after last encoded character if last character is one of these & < > ' ".


Test script:
---------------
<?php
echo htmlspecialchars('b<>"',ENT_QUOTES|ENT_SUBSTITUTE|ENT_HTML5,'UTF-8');
?>

Expected result:
----------------
b&lt;&gt;&quot;

Actual result:
--------------
b&lt;&gt;&quot;quot;

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-12 00:24 UTC] requinix@php.net
-Status: Open +Status: Feedback -Type: Feature/Change Request +Type: Bug
 [2015-11-12 00:24 UTC] requinix@php.net
https://3v4l.org/XTslX

I'm not seeing it. Are you sure that's the *exact* output? What if you try

<?php
header('Content-Type: text/plain');
echo htmlspecialchars('b<>"',ENT_QUOTES|ENT_SUBSTITUTE|ENT_HTML5,'UTF-8');
?>

and in a script all by itself?
 [2015-11-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 16:01:28 2024 UTC