Bug #68728 [Asn->Nab]: htmlentities() does not convert ' '/" to  /" with ENT_HTML5

From: Date: Wed, 15 Sep 2021 09:26:01 +0000
Subject: Bug #68728 [Asn->Nab]: htmlentities() does not convert ' '/" to  /" with ENT_HTML5
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236610@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68728&edit=1

 ID:                 68728
 Updated by:         cmb@php.net
 Reported by:        yohgaki@php.net
 Summary:            htmlentities() does not convert ' '/" to
                      /" with ENT_HTML5
-Status:             Assigned
+Status:             Not a bug
 Type:               Bug
 Package:            Strings related
 Operating System:   any
 PHP Version:        Irrelevant
-Assigned To:        yohgaki
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

> However, htmlentities() should convert all chars according to
> the conversion table.

No.  Quotes and apostophes are handled according to ENT_COMPAT,
ENT_QUOTES and ENT_NOQUOTES, and ENT_HTML5 does not imply
ENT_QUOTES nor ENT_COMPAT, so ENT_NOQUOTES is effective.

This default might not be the best choice, but the behavior is not
a bug, and changing it would require the RFC process because of
the BC break.


Previous Comments:
------------------------------------------------------------------------
[2015-02-11 01:46:03] yohgaki@php.net

I've proposed this change once. I may try it again.

------------------------------------------------------------------------
[2015-02-10 20:47:11] ppaisndud at gmail dot com

This line causes this,

https://github.com/php/php-src/blob/master/ext/standard/html.c#L1316-L1318

probably can be moved to verified if it is a error.

------------------------------------------------------------------------
[2015-01-03 01:25:53] yohgaki@php.net

Description:
------------
' ' space is &nbsp and it's in conversion tables.

localhost:Documents yohgaki$ php -r 'print_r(get_html_translation_table(ENT_HTML5));'
Array
(
    ["] => "
    [&] => &
    [<] => &lt;
    [>] => &gt;
    [ ] => &nbsp;
    [¡] => &iexcl;

but ' '/" is not converted to &nbsp;/&quot; with htmlentities() at least.
" is converted to &quot; with additional ENT_QUOTES flag. However, htmlentities() should
convert all chars according to the conversion table.


Test script:
---------------
php -r 'echo htmlentities("\" <>?&/", ENT_HTML5);'


Expected result:
----------------
&quot;&nbsp;&lt;&gt;&quest;&amp;&sol;

Actual result:
--------------
" &lt;&gt;&quest;&amp;&sol;


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=68728&edit=1


Thread (4 messages)

« previous php.bugs (#236610) next »