php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63806 html_entity_decode($x, ENT_QUOTES, "UTF-8") doesn't work as advertised wrt. "'"
Submitted: 2012-12-19 14:31 UTC Modified: 2012-12-19 19:51 UTC
From: t dot glaser at tarent dot de Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.4.9 OS: Debian experimental to get 5.4.9
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: t dot glaser at tarent dot de
New email:
PHP Version: OS:

 

 [2012-12-19 14:31 UTC] t dot glaser at tarent dot de
Description:
------------
http://de3.php.net/manual/en/function.html-entity-decode.php says:

        Available flags constants
Constant Name   Description
  ENT_COMPAT    Will convert double-quotes and leave single-quotes alone.
  ENT_QUOTES    Will convert both double and single quotes.
  ENT_NOQUOTES  Will leave both double and single quotes unconverted.
  ENT_HTML401   Handle code as HTML 4.01. 
  ENT_XML1      Handle code as XML 1. 
  ENT_XHTML     Handle code as XHTML. 
  ENT_HTML5     Handle code as HTML 5.

However, I don’t see ' being decoded with ENT_QUOTES.

Test script:
---------------
<?php
$x = "&apos;";
$y = html_entity_decode($x, ENT_QUOTES, "UTF-8");
echo "< $y >\n";


Expected result:
----------------
< ' >


Actual result:
--------------
< &apos; >


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-19 19:51 UTC] rasmus@php.net
This is not a bug. html_entity_decode() defaults to HTML4 entities. &apos; is not 
a valid HTML4 entity. If you try your code with &#39; you will see ENT_QUOTES 
includes single quotes just fine.

As of PHP 5.4 html_entity_decode() supports both XHTML and HTML5 entities. Use 
ENT_QUOTES|ENT_XHTML or ENT_QUOTES|ENT_HTML5 and you will see &apos; is converted 
as you would expect.
 [2012-12-19 19:51 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Feb 26 04:01:27 2020 UTC