Skip to content

fix(accept-header): reject out-of-range accept-language weights - #97878

Open
koatedevopskpai wants to merge 1 commit into
vercel:canaryfrom
koatedevopskpai:fix/accept-language-invalid-q-values
Open

fix(accept-header): reject out-of-range accept-language weights#97878
koatedevopskpai wants to merge 1 commit into
vercel:canaryfrom
koatedevopskpai:fix/accept-language-invalid-q-values

Conversation

@koatedevopskpai

@koatedevopskpai koatedevopskpai commented Aug 25, 2026

Copy link
Copy Markdown

acceptLanguage now rejects non-finite or out-of-range q-values (for instance: q=2, q=-0.5, q=abc, q=NaN) with the existing Invalid accept-language header error, instead of silently treating them as q=1. Near-zero weight values like q=0.0001 now rank as low priority. Their true position.

In the current state a disfavoured language was being sorted to the top. This was wrong. RFC 9110 defines q-values as strictly 0-1, this fix brings the implementation into spec.

I added new tests at:
packages/next/src/server/accept-header.test.ts
covering 5 cases:

  1. q=0 drop
  2. Valid boundary values
  3. Near-zero ranking
  4. Out-of-range throws
  5. Non-numeric throws

@koatedevopskpai
koatedevopskpai marked this pull request as ready for review August 25, 2026 16:08
@koatedevopskpai
koatedevopskpai force-pushed the fix/accept-language-invalid-q-values branch from 17665f0 to 2258b0e Compare August 25, 2026 17:26
@koatedevopskpai
koatedevopskpai force-pushed the fix/accept-language-invalid-q-values branch from 2258b0e to e7fc835 Compare August 25, 2026 17:41
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.

1 participant