Bug 262635 - FetchResponse.formData() should parse headers names as case insensitive
Summary: FetchResponse.formData() should parse headers names as case insensitive
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Safari 17
Hardware: All All
: P2 Critical
Assignee: sideshowbarker
URL: https://jsfiddle.net/x0o1mqj8/
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-10-04 11:21 PDT by Jimmy Wärting
Modified: 2023-10-10 09:13 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jimmy Wärting 2023-10-04 11:21:49 PDT
## reproducible code:

async function init() {
  var fd = new FormData()
  fd.set('x', 'y')
  var blob = await new Response(fd).blob()
  var body = await blob.text()
  blob = new Blob([body.toLowerCase()], { 
    // convert boundary to lowercase also.
    type: blob.type.toLowerCase() 
  })
  fd = await new Response(blob).formData()
  console.log([...fd])
}

init()


## Test page:
https://jsfiddle.net/x0o1mqj8/


Works in Firefox, and all chromium browsers
fails in safari
Comment 1 sideshowbarker 2023-10-05 05:36:06 PDT
Pull request: https://github.com/WebKit/WebKit/pull/18689
Comment 2 sideshowbarker 2023-10-05 05:42:21 PDT
If we do actually want to have interop on this, I can add WPT tests to the PR — and also I guess, update the algorithm at https://fetch.spec.whatwg.org/#dom-body-formdata to explicitly that the Content-Disposition and Content-Type headers names must be parsed case-insensitively. (Though, as noted in the comment which follows that algorithm in the spec: The algorithm is just “a rough approximation of what is needed for multipart/form-data” — that is, it’s already recognized to be underspecified…)
Comment 3 sideshowbarker 2023-10-10 08:43:20 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/42455
Comment 4 EWS 2023-10-10 09:12:31 PDT
Committed 269144@main (d0c370d532ad): <https://commits.webkit.org/269144@main>

Reviewed commits have been landed. Closing PR #18689 and removing active labels.
Comment 5 Radar WebKit Bug Importer 2023-10-10 09:13:17 PDT
<rdar://problem/116742000>