Closed Bug 1508699 Opened 6 years ago Closed 5 years ago

Fetch() should not store lowercase header names

Categories

(Core :: DOM: Core & HTML, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla66
Tracking Status
firefox65 --- wontfix
firefox66 --- fixed

People

(Reporter: baku, Assigned: baku)

Details

Attachments

(1 file, 1 obsolete file)

We currently "lowercase" header names. This is not written in the spec and it makes several WPTs to fail. We also don't merge headers. I'll fix this in the same patch.
Attached patch name.patch (obsolete) — Splinter Review
"A header list list contains a name name if list contains a header whose name is a byte-case-insensitive match for name. "
Attachment #9026433 - Flags: review?(bugmail)
Attached patch name.patchSplinter Review
Attachment #9026433 - Attachment is obsolete: true
Attachment #9026433 - Flags: review?(bugmail)
Attachment #9026441 - Flags: review?(bugmail)
Priority: -- → P2
asuth, can you take a look at this patch?
Flags: needinfo?(bugmail)
Comment on attachment 9026441 [details] [diff] [review]
name.patch

Review of attachment 9026441 [details] [diff] [review]:
-----------------------------------------------------------------

restating:
- Some nsACString types are converted to nsCString because .get() is used and nsCString guarantees zero-termination but nsACString is dumb and does not.
- Capitalization is ignored throughout the logic except...
- The first capitalization seen for a (case-insensitive) header name is latched so that if we see "foo" then "fOO" then "Foo", "foo" will win.

::: dom/fetch/FetchDriver.cpp
@@ +1450,5 @@
>  FetchDriver::SetRequestHeaders(nsIHttpChannel* aChannel) const
>  {
>    MOZ_ASSERT(aChannel);
>  
> +  // nsIHttpChannel has a set of pre-configured headers (Accept,

Thanks for this very helpful comment!

::: dom/fetch/InternalHeaders.cpp
@@ +524,5 @@
>      }
>  
>      if (!found) {
> +      Entry newEntry = entry;
> +      ToLowerCase(newEntry.mName);

Restating: The "sort and combine" algorithm at https://fetch.spec.whatwg.org/#concept-header-list-sort-and-combine calls for the headers to be byte-lowercased.  Previously, this was handled by everything being lowercased, but since the names are no longer normalized to be lowercased elsewhere in the class, the normalization needs to happen here.

::: dom/fetch/InternalHeaders.h
@@ +160,5 @@
>             IsForbiddenRequestNoCorsHeader(aName, aValue) ||
>             IsForbiddenResponseHeader(aName);
>    }
>  
> +  void ReuseExistingNameIfExists(nsCString& aName) const;

Please add a comment explaining the intent of this method.  Something like:

This method updates the passed name to match the capitalization of a header with the same name (ignoring case, per the spec).
Attachment #9026441 - Flags: review?(bugmail) → review+
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/0edf62695f1d
Fetch() should not send lowercase header names, r=asuth
https://hg.mozilla.org/mozilla-central/rev/0edf62695f1d
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
Flags: needinfo?(bugmail) → in-testsuite+
Component: DOM → DOM: Core & HTML
Type: enhancement → defect
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: