Re: ENT_COMPAT for htmlentities and htmlspecialchars
| From: | Craig Francis | Date: | Thu, 07 Jan 2021 15:09:16 +0000 |
| Subject: | Re: ENT_COMPAT for htmlentities and htmlspecialchars | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112797@lists.php.net to get a copy of this message | ||
On Thu, 7 Jan 2021 at 14:11, Claude Pache <claude.pache@gmail.com> wrote:
> Hi,
>
> > Le 26 déc. 2020 à 12:02, Craig Francis <craig@craigfrancis.co..uk> a
> écrit :
> >
> > (...)
> > PHP uses the numeric version ' with ENT_QUOTES, and it should
> continue
> > to do so - because the named version, ' was added in HTML5, but can
> > still cause problems with legacy parsers; for example Android 4, and the
> > one still in use by Microsoft Outlook (&/>/< was in the
> > original HTML spec, and " was added in HTML2).
> >
> > (...)
>
> I agree that — in addition to ENT_QUOTES — ENT_HTML401 (which encodes
> quotes as ') is a better default when encoding, but I also think that
> ENT_HTML5 (which recognises both ' and ') is a better default
> when decoding.
>
That's a good point for decoding, if I saw:
echo html_entity_decode(' ' ' ')
I would expect it to decode both.
I'm tempted to update my PR to use ENT_HTML5 on
html_entity_decode and
htmlspecialchars_decode, to avoid that issue.
But the tests show that it affects a few others, which I think are fine,
but should check what others think:
 > DECODED, Form Feed

 > NOT DECODED, Carriage Return
 > NOT DECODED, Invalid character
 > NOT DECODED, Invalid character
 > NOT DECODED, Invalid character
 > NOT DECODED, Invalid character
 > NOT DECODED, Not a character
 > NOT DECODED, Not a character
Craig