Skip to content

gate-41 (html-lang) has gate-38's defect verbatim: a PHP COMMENT mentioning <html> makes a mount point a page root #266

Closed

Description

@rubenvdlinde

Found while fixing gate-38 (#214/#216/#227). Not fixed there — different gate, and the fix is one line now that the helper exists.

Reproduction, against merged main (6430233)

templates/fragment.php — a mount point that emits no <html> at all:

<?php
// This mount point is substituted into core's page. Core emitted the
// <html> element for it, with its lang attribute, long before this file.
?>
<div id="app-settings"></div>
[gate-41] html-lang: FAIL — 1 <html> tag(s) without lang=
templates/fragment.php: <html> rule=html-tag-without-lang

The file contains no <html> element. The gate matched the comment explaining that it doesn't.

Cause

m = re.search(r'<html\b([^>]*)>', txt, re.IGNORECASE)

txt is the raw file. This is the gate-64 defect and the one gate-38 just shipped a fix for: a checker that greps a string literal misses every constant and matches every comment, failing both ways at once. It also fails the other way — a commented-out <html lang="en"> would satisfy the gate for a template that really does emit an unlangged <html>.

The fix already exists

scripts/lib/php_template_scope.py (landed in #247) classifies emitted markup with PHP regions and HTML comments removed, and is tested for exactly these two comment shapes. gate-41 should run its search over php_template_scope.emitted_markup(src) instead of the raw text.

Two related loose ends in the same block

  1. A third scope definition. gate-41 still enumerates its own find templates appinfo/templates -name '*.php' (line ~3853). fix(gates): the a11y family read only Vue, so a PHP-template app got a green over nothing (#225) #261 introduced _a11y_markup_files and fix(gate-38): a mount point is not a page root, and the remedy it demanded regressed a11y (#214, #216, #227) #247 converged gate-38 onto it; gate-41 is the last a11y gate with a private enumeration, so a generated phpmetrics/ or vendor/ template is audited here and nowhere else.
  2. No wiring guard. The block is an inline python3 - <<'PYHL' >> log 2>/dev/null, so a crashed interpreter leaves an empty log and the gate reports PASS (fix(gates): 16 gates reported PASS when their helper never ran — 2 are authorization gates #147 / fix(gate-19): read the test file with a parser, not three regexes (#234, #239, #244) #249).

Why this is currently invisible

gate-41 reports PASS across the fleet because no app template emits a document — measured: all 30 are fragments. The false positive only fires on a template whose prose mentions the tag. So the gate is quiet today for a reason unrelated to it being correct, and the first app that writes such a comment gets an unclosable finding.

Activity

  1. rubenvdlinde commented on Aug 8, 2026

    @rubenvdlinde
    ContributorAuthor

    Fixed and merged to main in #269 (cdfbd7a). Live fleet-wide now. All three loose ends closed, exactly as scoped.

    1. The comment defect. The search runs over php_template_scope.emitted_markup(src) — the helper #247 landed — instead of the raw text, so neither a PHP comment naming the tag nor a commented-out <html lang="en"> can decide it. Your reproduction is a unit test verbatim, with all four arms:

    • a mount point whose comment mentions <html> → 0
    • a template that really emits <html> with no lang → 1 (the positive control; without it "no findings" proves nothing here, since the gate is quiet fleet-wide for reasons unrelated to being correct)
    • <html lang="en"> → 0
    • <!-- <html lang="en"> --> above a real unlangged <html> → 1 (the more dangerous direction you named)

    [^>]* went too — a > inside an attribute value is not the end of the tag (#198, #236) — and every emitted <html> is now checked, not just the first.

    2. The third scope definition. Gone. gate-41 reads _a11y_markup_files filtered to .php, so a generated phpmetrics/ or vendor/ template is no longer audited here and nowhere else. There are two definitions in the a11y family now, not three, and one of them is shared — no new dialect was introduced, per your "converge, don't add a third".

    3. The wiring guard. The inline python3 - <<'PYHL' >> log 2>/dev/null is gone. A missing or crashing helper now reports SKIPPED (wiring) naming how many templates went uninspected, never PASS (#147 / #249). Both failure shapes — helper absent and helper crashing — are asserted in test_gate_a11y_helper_wiring.sh, alongside a positive control proving the gate FAILs on a template that really does emit an unlangged document.

    Measured post-merge on nldesign, larpingapp, openconnector, procest and openbuild: [gate-41] html-lang: PASS in both arms — as you predicted, because no app emits a document. The difference is that it is now PASS for the right reason, and a repo that writes such a comment no longer gets an unclosable finding.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions