Skip to content

Stdlib: html_entity_decode() / htmlspecialchars_decode() — ENT_HTML5 named entities #4130

Description

@PurHur

Category

stdlib

Problem

html_entity_decode() and htmlspecialchars_decode() ignore ENT_HTML5 (constant 48): HTML5 named entities such as ',  , ½, and © are left unchanged. Zend decodes them when ENT_HTML5 is set in the quote-style flags.

php-src reference

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
cat > /tmp/ent_html5.php <<'"'"'PHP'"'"'
<?php
$flags = ENT_QUOTES | ENT_HTML5;
echo html_entity_decode("&apos;", $flags), "\n";
echo html_entity_decode("&nbsp;", ENT_HTML5), "\n";
echo html_entity_decode("&frac12;", ENT_HTML5), "\n";
PHP
php /tmp/ent_html5.php
php bin/vm.php /tmp/ent_html5.php
'
Input Zend (ENT_HTML5) This compiler
&apos; + ENT_QUOTES|ENT_HTML5 ' &apos;
&nbsp; U+00A0 (non-breaking space) &nbsp;
&frac12; ½ &frac12;

Scope (this repo)

  • ext/standard/VmString.php — extend htmlspecialchars_decode() / entity table lookup for HTML5 names
  • ext/standard/html_entity_decode.php, htmlspecialchars_decode.php — pass ENT_HTML5 flag through
  • JIT/AOT paths registered alongside VM handlers
  • test/compliance/cases/stdlib/html_entity_decode_ent_html5.phpt

Related: #2472 (ENT_COMPAT subset); this is the HTML5 named-entity gap.

Done when

  • VM + JIT + AOT: repro script output matches Zend byte-for-byte (or codepoint-normalized for &nbsp;)
  • ENT_HTML5 without other flags follows php-src rules for which entities decode
  • Compliance .phpt under test/compliance/cases/stdlib/ compares Zend vs VM on the repro script

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions