ReviewOS

zig-utils/zig-js

Request: validate and preserve exposed RequestInit string state

#689
Closed chris opened this 9 days ago ·
9 days ago

Parent: #473

Standards: https://fetch.spec.whatwg.org/#request-class and https://webidl.spec.whatwg.org/#js-dictionary

Problem

The exposed Request constructor currently accepts arbitrary cache/credentials/mode/redirect strings, accepts invalid or forbidden methods, reads supported RequestInit members outside Web IDL lexicographic order, stores integrity through physical StringData bytes, and resets inherited request state to defaults when constructing from another Request.

Scope

  • Convert the currently exposed RequestInit members in Web IDL order: body, cache, credentials, headers, integrity, keepalive, method, mode, redirect.
  • Enforce RequestCache, RequestCredentials, RequestMode, and RequestRedirect enum values.
  • Enforce ByteString and HTTP token constraints for method, reject CONNECT/TRACE/TRACK, and normalize the six Fetch-normalized methods.
  • Reject mode navigate and only-if-cached unless mode is same-origin.
  • Canonicalize persistent DOMString integrity.
  • Preserve cache/credentials/mode/redirect/integrity/keepalive when constructing from an existing Request unless init overrides them.
  • Preserve exact getter/coercion order and abrupt completion.

This issue does not touch promises, jobs, queues, workers/threads, or Map/Set iterators.

Acceptance

  • Valid state round-trips and inherited Request construction preserves it.
  • Invalid enum, ByteString, token, forbidden-method, navigate, and cache/mode combinations throw TypeError.
  • Supported dictionary getters run once in lexicographic order.
  • Integrity survives canonical and forced-flat physical StringData storage with one coercion.
  • Focused Debug, ReleaseSafe, and TSan tests pass; full sharded units have zero failures/leaks.
  • Test262 Web API coverage is inventoried explicitly; a zero denominator is no corpus claim.
9 days ago

Implemented by fix(request): validate and preserve RequestInit state (#689). The constructor now converts supported RequestInit members in Web IDL order, validates enums and ByteString/HTTP methods, enforces Fetch cross-member rules (including no-cors safelisted methods), and preserves canonical exposed state across copies and clones. Validation: focused state witness 1/1 in Debug, forced-flat storage, ReleaseSafe, and TSan; member-order witness 1/1; full units 1783 passed, 1 skipped, 0 failed, 0 leaked across 6 shards. The Test262 Request inventory is 0 files, so no corpus conformance claim is made. Remaining RequestInit members stay tracked in #690.

Sign in to comment on this issue.