Skip to content

fix(rules): meta-title whitespace, charset placement advice, tel (0) trunk prefix (#658, #659, #663) - #676

Merged
nc9 merged 8 commits into
mainfrom
fix/rule-fixes-658-659-663
Oct 11, 2026
Merged

nc9 merged 8 commits into
mainfrom
fix/rule-fixes-658-659-663

Conversation

@nc9

@nc9 nc9 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Three rule fixes reported from the 84-site audit corpus.

Closes #658
Closes #663
Refs #659 (the header-based criteria wait on #674, see below)

#658 core/meta-title: measure the displayed title

The rule measured title.length on the raw <title> source, so a theme that indents the title across lines (Shopware, Shopify) got Title too long for its indentation. It now measures the title as document.title gives it: runs of ASCII whitespace (space, tab, LF, FF, CR) collapse to one space and the ends are trimmed. The finding's value and item label show that collapsed text. A no-break space is not collapsed. A whitespace-only title is reported missing, the same as <title></title>. Over-long and too-short titles still warn.

#659 core/charset: placement advice vs encoding problems

  • UTF-8 declared correctly but the charset meta not first in <head>: status info, message UTF-8 is declared correctly; consider placing the charset meta first in head (best practice). info is score-neutral (calculateRuleScore skips it), below the warn/fail of the missing and conflicting cases, which keep their status.
  • New: a charset-declaring <meta> (either form) that does not end within the first 1024 bytes of the raw HTML warns Charset meta is not within the first 1024 bytes (HTML Standard 4.2.5.4), even when the header also says UTF-8. The scan is bounded to the first 1024 UTF-16 code units, skips comments and other tags the way the prescan does, handles quoted > and open quotes, and counts UTF-8 bytes. Pages crawled with browser rendering are not measured, because their HTML is the serialized DOM.
  • New: header and page disagreeing about UTF-8 warns Conflicting charset declarations: header <h>, page <p>. I chose warn because the header decides the decoding, so the effective encoding is the same non-UTF-8 the rule already warns about (Non-UTF-8 charset declared), while fail stays reserved for no declaration at all. Two different non-UTF-8 labels are not called a conflict, since the labels can name one encoding. The judged value is now the header's when it names one (the browser's precedence), and a quoted header charset is unquoted.

Not end to end yet (#674): the crawler keeps only the media type of Content-Type (packages/crawler/src/fetcher.ts normalizeContentType), so in a real audit ctx.page.headers["content-type"] never carries a charset. A page declared UTF-8 only by its header reports No charset declaration found today (on 0.0.108 too), and the conflict warning cannot fire. Met end to end: placement advice and the 1024-byte check (criteria 1 for meta declarations, 2, 3). Met only in rule unit tests until #674 lands: header-declared UTF-8 and the header/meta conflict (criterion 1 for headers, criterion 4's conflict case). The rule docs and CHANGELOG say so.

#663 links/tel-mailto: optional trunk prefix (0)

<a href="tel:+4960616309800">+49 (0)6061 630 980 0</a> is no longer tel-mismatch. The display text (never the href) is read with the parenthesised trunk prefix omitted, and when that matches the href the link gets a new tel-trunk-prefix check at info: <count> tel link(s) show the optional trunk prefix (0) in an international number; drop it (ITU-T E.123), item text "<text>": use "<international form>". This reading is limited to calling codes whose national trunk prefix is 0 and is omitted internationally, per the ITU-T dialling procedures list (annex to Operational Bulletin 994), cited in the code: +31, +32, +33, +41, +43, +44, +49, +61, +64, +353. Countries with no trunk prefix keep their zero (Italy +39, Spain +34 stay mismatches), and a display number that really differs still reports tel-mismatch. The (0) reading runs before the 3-consecutive-digit gate, so grouped numbers such as +33 (0)1 23 45 67 89 are covered, and it needs at least 7 interpreted digits.

Heads up: info checks are invisible in reports today (#669)

The placement advice (#659) and the tel formatting advice (#663) are info checks. Info checks never appear in the CLI text, LLM or JSON output, because report grouping skips a rule that has no warn or fail. So both pieces of advice are score-neutral and are not shown in reports until #669 lands. They are in the stored rule results (verified below). For the reporter: after this change those pages simply stop showing the finding.

Verification

  • New tests: packages/rules/tests/core-meta-title.test.ts, core-charset.test.ts, and a links/tel-mailto: distinguish optional German trunk-prefix notation from a destination mismatch #663 block in tel-mailto.test.ts. 49/49 pass. Run against the origin/main rule code, the new behaviour tests fail (22 of them, plus 3 more for the review fixes). The controls and unchanged cases pass on both.
  • Related tests pass: title-pattern-outlier, template-verdict-page-independence, private-target-skip, noindex-skip, rule-verdict-scope (485), audit-engine template-fanout-parity-golden and fingerprint-parity (60). tsgo --noEmit on packages/rules is clean. tangly check --strict passes.
  • rule-cache-replay-golden.test.ts: 10 of 11 pass locally. "a page where a rule timed out is not stored" hangs to its 180 s timeout on this machine with pristine origin/main rule files too (3-run matrix: all-main hung 2 of 3), and rule-time-budget.test.ts fails 9/20 here on main, so this looks like a local node:vm watchdog flake, not this change. CI on Linux is the judge.
  • CLI before/after on local fixtures (0.0.108 binary vs this branch from source, --http --refresh -m 1 --rule-include <rule>):
    • padded title: warn Title too long (121 chars, raw) before; pass with value Tret- & Kinderroller kaufen - Preiswert after. Control unchanged.
    • viewport-first charset: warn ... not at start of head before; stored rule result info UTF-8 is declared correctly; ... after. Control passes.
    • charset meta after a 2,000-byte comment: pass before; warn Charset meta is not within the first 1024 bytes after.
    • +49 (0)6061 630 980 0: tel-mismatch before; stored tel-trunk-prefix info with use "+49 6061 630 980 0" after. +49 (0)6061 630 980 1 still tel-mismatch.
  • Two codex review rounds. Fixed: a quote-aware prescan tokenizer (no <meta-data>, no <meta inside another tag's attribute, an open quote runs to the window end) and the (0) reading ahead of the digit gate. Kept as a documented limit: the decoded body has lost any UTF-8 BOM, so such a page is measured 3 bytes short (its BOM decides the decoding anyway).

Docs and skill

Docs updated in this PR: docs/rules/core/meta-title.mdx, docs/rules/core/charset.mdx, docs/rules/links/tel-mailto.mdx (message templates, the country list with sources, the #674 limit). CHANGELOG has entries under Unreleased. The squirrelscan agent skill needs no change: no CLI surface, rule id or option changed.

@nc9
nc9 marked this pull request as ready for review October 11, 2026 21:07
@claude

claude Bot commented Oct 11, 2026

Copy link
Copy Markdown

Reviewed the diff for the charset, meta-title and tel-mailto rule changes. I found no blocking problems. I only read the code and did not run the test suite.

Performance and security: PRESCAN_TOKEN runs on at most 1024 code units, and its alternatives are disjoint on their first character, so I see no ReDoS risk. The behaviour is documented and tested, and the docs and changelog are updated.

@nc9
nc9 merged commit a2886d1 into main Oct 11, 2026
16 checks passed
@nc9
nc9 deleted the fix/rule-fixes-658-659-663 branch October 11, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

links/tel-mailto: distinguish optional German trunk-prefix notation from a destination mismatch core/meta-title: title length counts raw whitespace

1 participant