Skip to content

Regression: DOMDocument::loadHTML(File)/DOMNodeList::item excess argc silently accepted — Zend ArgumentCountError (ext/dom) #30835

Description

@PurHur

Category

Regression · php-src-strict · excess argc · ext/dom

Problem

DOMDocument::loadHTML(), DOMDocument::loadHTMLFile(), and DOMNodeList::item() silently accept excess arguments on VM. Zend throws ArgumentCountError. Sibling class of closed ChildNode #30814 / XMLReader #30641; open peers XMLWriter #30818 / SimpleXML #30828.

Probed 2026-08-13 — host Zend PHP 8.2.32 vs VM @ fb52e8743e.

Repro Zend 8.2.32 VM
(new DOMDocument)->loadHTML('<p>x</p>', 0, 'x') ArgumentCountError: … at most 2 …, 3 given ok (ACCEPTED)
->loadHTMLFile('/etc/hosts', 0, 'x') … at most 2 …, 3 given ACCEPTED
$d->getElementsByTagName('a')->item(0, 'x') … exactly 1 …, 2 given returns node (ACCEPTED)

Note: loadXML / saveHTML / createElement / appendChild already throw ACE on VM — only these HTML/NodeList entry points are soft.

php-src reference

PHP implementation target

  • ext/dom/DocumentLoadHTML.php, DocumentLoadHTMLFile.php (+ JitDomLoadHTML* / helpers)
  • ext/dom/NodeListItem.php (+ JitDomNodeListItem*)
  • Shared Zend-shaped argc guard; no new C in runtime/

Repro

./script/docker-exec.sh -- bash -lc 'php -r '\''=new DOMDocument(); try { ->loadHTML("<p>x</p>",0,"x"); echo "ACCEPTED\n"; } catch (Throwable ) { echo ->getMessage(),"\n"; }'\'''
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r '\''=new DOMDocument(); try { ->loadHTML("<p>x</p>",0,"x"); echo "ACCEPTED\n"; } catch (Throwable ) { echo ->getMessage(),"\n"; }'\'''

Done when

  • VM (+ JIT when wired): excess argc → Zend-shaped ArgumentCountError for loadHTML, loadHTMLFile, DOMNodeList::item
  • Repro under test/repro/ + smallest compliance VM/JIT pair
  • php-src-strict; no php-compiler-strict shortcut

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 machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions