Skip to content

crawler: the Content-Type charset never reaches rules, so a header-only UTF-8 page fails core/charset #674

Closed

Description

@nc9

Summary. The crawler keeps only the media type of the Content-Type header, so rules never see its charset parameter. A page that declares UTF-8 only in the HTTP header (no <meta charset>) is reported by core/charset as No charset declaration found, a failure on a correctly declared page.

Where. packages/crawler/src/fetcher.ts normalizeContentType (around line 648) keeps only the media type, at about lines 846 (all fetchers, cloud render included) and 1090. The stored page headers JSON holds {"contentType":"text/html"}. The audit engine's buildHeadersMap (packages/audit-engine/src/adapter.ts, around line 1079) is the only path from stored headers to rules, so ctx.page.headers["content-type"] never carries a charset.

Seen on 0.0.108 and current main with a local fixture: a page served with Content-Type: text/html; charset=utf-8 and no charset meta gets fail No charset declaration found. A header of iso-8859-1 with a utf-8 meta produces no finding, although the rule's unit test flags it. So the rule's header branches work in unit tests but never in a real audit.

Scope note. Carrying the charset through means a new header field in the crawler types and fetcher, the stored headers, and buildHeadersMap. The cloud also persists page headers (the cloud audit runtime checkpoint contract and the API's crawl content), so the change spans both repos and needs a rollout order. Found while fixing #659.

Acceptance Criteria

  • A page declared UTF-8 only by the Content-Type header (no meta) passes core/charset, in a real audit on the CLI.
  • A header charset that conflicts with the meta charset (for example header iso-8859-1, meta utf-8) is reported, in a real audit.
  • The charset reaches rules through the page headers for every fetcher (HTTP, cloud render, cache replay).
  • Previously stored pages (headers without a charset) still load, and the rule treats a missing charset parameter the same as today.
  • A test runs the real fetcher, store and rule path, not only the rule in isolation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bugrulessize: M

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions