Validate statusText as a reason phrase under pedantic_wpt by npaun · Pull Request #7840 · cloudflare/workerd · GitHub
Skip to content

Validate statusText as a reason phrase under pedantic_wpt - #7840

Open
npaun wants to merge 1 commit into
mainfrom
npaun/pedantic-wpt-status-text-bytestring
Open

npaun wants to merge 1 commit into
mainfrom
npaun/pedantic-wpt-status-text-bytestring

Conversation

@npaun

@npaun npaun commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

ResponseInit.statusText is a WebIDL ByteString, so any code unit above 0xFF must throw a TypeError. "Initialize a response" then also throws a TypeError if a non-empty statusText doesn't match the HTTP reason-phrase production, *( HTAB / SP / VCHAR / obs-text ), where obs-text is %x80-FF.

The issue asks for ASCII validation, but that's stricter than the spec. obs-text allows 0x80–0xFF, and WPT's response-init-001 expects "\x80" to be accepted and returned as-is.

With pedantic_wpt enabled, compared with the existing check (which rejects only code units below 0x20), statusText validation now:

  • rejects code units above 0xFF, such as U+0100 (WPT response-error.any.js)
  • rejects DEL (0x7F), which is not a VCHAR
  • accepts HTAB, which the production allows. KJ HTTP rejects only CR, LF and NUL in a status line.

Fixes #4971

Compatibility

All three changes are gated on the existing pedantic_wpt flag.

Reviewer notes

  • Existing behaviour, out of scope here: obs-text is sent on the wire as UTF-8 ("\x80" → C2 80), not as the single byte.

ResponseInit.statusText is a WebIDL ByteString, so converting a
string containing any code unit above 0xFF throws a TypeError.
"Initialize a response" then throws a TypeError if a non-empty
statusText does not match the HTTP reason-phrase production,
*( HTAB / SP / VCHAR / obs-text ), where obs-text is %x80-FF.

The issue asks for ASCII validation, but that is stricter than the
spec: obs-text admits 0x80-0xFF, and WPT's response-init-001
expects a statusText of "\x80" to be accepted and returned as-is.

workerd's existing check rejects only code units below 0x20. With
pedantic_wpt enabled, statusText is now validated as the spec
requires. Compared with the existing check, that:

- rejects code units above 0xFF, such as U+0100 (WPT's
  response-error.any.js);
- rejects DEL (0x7F), which is not a VCHAR; and
- accepts HTAB, which the reason-phrase production allows. KJ
  HTTP rejects only CR, LF and NUL in a status line, so a tab is
  safe to send.

Compatibility: all three changes are gated behind the existing
pedantic_wpt flag, which has no enable date. The new rejections
throw on input that is currently accepted, and accepting HTAB is
gated alongside them so that behaviour without the flag is
unchanged.

Testing: tests were not run locally because a WARP outage made
the cfdata.org dependency, remote cache and credential hosts that
edgeworker's bazel needs unreachable. CI is the verification.

Fixes #4971

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@npaun
npaun force-pushed the npaun/pedantic-wpt-status-text-bytestring branch from abe170a to 1c8e493 Compare October 20, 2026 04:48
@npaun
npaun marked this pull request as ready for review October 20, 2026 04:51
@npaun
npaun requested review from a team as code owners October 20, 2026 04:51
@clanky-the-clanker

Copy link
Copy Markdown

@ask-bonk

ask-bonk Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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.

If pedantic_wpt is set, validate that statusText is ASCII

2 participants