Fetch: validating headers in Headers.set() - #1107
Closed
VadimZhestikov wants to merge 1 commit into
Closed
Conversation
Headers.set() validated its arguments only when the header did not already exist, in which case it fell through to ngx_js_headers_append(). When the header was present its value was overwritten in place, so the name and value checks and the immutable guard were all skipped. Now the same checks are done before the lookup, in both engines.
Contributor
|
See #1108. I do not amend it here because no original changes left. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Headers.set()validates its arguments only when the header does not alreadyexist. In that case it falls through to
ngx_js_headers_append(), which trimsoptional whitespace and then checks the name with
ngx_js_check_header_name(),the value with
ngx_js_check_header_value(), and the immutable guard.When the header is already present,
set()takes a different path: it finds theexisting entry, overwrites
h[i].valuein place and unlinks the duplicates, sonone of those checks run. As a result a value that
append()rejects isaccepted by
set():The immutable guard is skipped on the same path, so an existing header on an
immutable Headers object can be overwritten.
This moves the checks ahead of the lookup so both paths behave identically. Both
engines have the same structure and both are changed.
After the change the example above throws for
set()as well,set()with anordinary value still works, and optional whitespace is trimmed as it is by
append().Checklist
Before creating a PR, run through this checklist and mark each as complete:
CONTRIBUTINGdocument