Req #77769 [NEW]: html_entity_decode does not decode all HTML5 entities

From: Date: Tue, 19 Mar 2019 20:10:11 +0000
Subject: Req #77769 [NEW]: html_entity_decode does not decode all HTML5 entities
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220079@lists.php.net to get a copy of this message
From: cananian at wikimedia dot org Operating system: n/a PHP version: 7.3.3 Package: Strings related Bug Type: Feature/Change Request Bug description:html_entity_decode does not decode all HTML5 entities Description: ------------ The latest HTML5 specs contain a number of "semicolon-less" entities which are decoded in most circumstances. See the list at https://html.spec.whatwg.org/#named-character-references (just the ones which don't end in a semicolon). These are decoded *except* when found in an attribute and the letter after the entity is an equals sign or an ASCII alphanumeric; see https://html.spec.whatwg.org/#named-character-reference-state I propose two new option flags for html_entity_decode: ENT_HTML5_NOATTRIBUTE -- decodes all the semicolon-less entities in addition to the other HTML5 entities ENT_HTML5_ATTRIBUTE -- decodes semicolon-less entities except when they are followed by an equals sign or ASCII alphanumeric This would allow authors to easily decode these legacy semicolon-less entities in the same way a browser would. Test script: --------------- In PHP: $ psysh Psy Shell v0.9.9 (PHP 7.3.2-3 — cli) by Justin Hileman >>> html_entity_decode('&ampfoo', ENT_HTML5) => "&ampfoo" In a browser web console: >document.body.innerHTML="&ampfoo" "&ampfoo" > document.body.innerHTML "&foo" -- Edit bug report at https://bugs.php.net/bug.php?id=77769&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77769&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77769&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77769&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77769&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77769&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77769&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77769&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77769&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77769&r=support Expected behavior: https://bugs.php.net/fix.php?id=77769&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77769&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77769&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77769&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77769&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77769&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77769&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77769&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77769&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77769&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77769&r=mysqlcfg

« previous php.bugs (#220079) next »