Skip to content

Stdlib: htmlspecialchars()/htmlentities() — ENT_HTML5 must emit ' not ' for apostrophe (ext/standard/html.c) #4958

Description

@PurHur

Category

stdlib · HTML encoding (encode path; #4130 covers decode)

Problem

With ENT_QUOTES | ENT_HTML5, encoding a single apostrophe must produce the named entity ' per Zend / HTML5 rules. This compiler emits the numeric entity ' instead.

#4130 tracks html_entity_decode / htmlspecialchars_decode ENT_HTML5 decode parity; this issue is the encode side in htmlspecialchars() / htmlentities().

php-src reference

Repro

test/repro-maintainer/repro_htmlspecialchars_ent_html5.php:

<?php
echo htmlspecialchars("'", ENT_QUOTES | ENT_HTML5), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/repro_htmlspecialchars_ent_html5.php
php bin/vm.php test/repro-maintainer/repro_htmlspecialchars_ent_html5.php'
Runtime Output
Zend PHP &apos;
VM &#039;

(Without ENT_HTML5, both correctly emit &#039;.)

Scope (this repo)

Area Path
VM builtin ext/standard/ htmlspecialchars lowering / entity tables
Tests test/compliance/cases/stdlib/htmlspecialchars_ent_html5.phpt

Done when

  • Repro output matches Zend (&apos;) under php bin/vm.php
  • ENT_QUOTES without ENT_HTML5 unchanged (&#039;)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro-maintainer/repro_htmlspecialchars_ent_html5.php'

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 3, 2026
  2. PurHur commented on Jun 12, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-c — starting this run

  3. PurHur commented on Jun 12, 2026

    @PurHur
    OwnerAuthor

    Merged via #8121.

    Verification:
    ```bash
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php test/repro-maintainer/repro_htmlspecialchars_ent_html5.php
    php bin/vm.php test/repro-maintainer/repro_htmlspecialchars_ent_html5.php'
    ```
    Zend + VM both output:
    ```
    '
    '
    '
    ```

    ```bash
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter htmlspecialchars_ent_html5'
    ```
    OK (4 tests, 4 assertions) — VM + JIT compliance.

  4. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — htmlentities ENT_HTML5 apostrophe (#4958)

  5. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    Merged #17035 — htmlEntitiesMapForFlags() now sets apostrophe to ' under ENT_QUOTES|ENT_HTML5; compliance htmlspecialchars_ent_html5*.phpt green on VM+JIT.

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