Headers set validation - #1108
Open
xeioex wants to merge 2 commits into
Open
Conversation
xeioex
force-pushed
the
headers-set-validation
branch
2 times, most recently
from
August 13, 2026 00:49
c8bdbfa to
52980b1
Compare
3 tasks
xeioex
force-pushed
the
headers-set-validation
branch
from
August 13, 2026 01:13
52980b1 to
b2ed5cd
Compare
VadimZhestikov
previously approved these changes
Aug 13, 2026
VadimZhestikov
left a comment
Contributor
There was a problem hiding this comment.
Looks good
A small follow-up simplification you might fold in, if you like it:
VadimZhestikov@a554b9fc
Two things on top of this PR, both no-op refactors:
- The per-engine
ngx_js_headers_update()/ngx_qjs_headers_update()
wrappers only forward tongx_js_headers_modify()and translate the
result code.append()andset()can callngx_js_headers_modify()
and*_headers_result()directly, so the wrappers are dropped. ngx_js_headers_modify()tookvalue/vlenby pointer, which reads
like an output parameter, but no caller uses the trimmed value back
(it's stored inside the function). Passing them by value removes the
indirection.
No functional change; the fetch tests pass on both njs and QuickJS. The
commit sits right on top of the current PR tip (b2ed5cd), so it applies
clean. Feel free to squash it in or ignore.
Previously, Headers.set() validated its arguments only when the header did not already exist. Existing values were overwritten without trimming or validating the new value and without checking the immutable guard. It also detached duplicate values only from the first header's chain, while leaving the corresponding list entries active. The stale values could reappear when the Headers object was copied or serialized. The fix is to move append(), set(), and delete() validation and list updates into engine-independent helpers, deactivate every duplicate on replacement, reject empty names, and enforce immutable guards consistently. Content-Type presence is now derived from the header list instead of a separate cached pointer. Reported by vladimirelitokarev@gmail.com.
Previously, Headers.set() converted the header name with JS_ToCStringLen(). When a new header was added, the list retained that pointer after it was released with JS_FreeCString(), leaving the header with a dangling name. The fix is to copy the name into the request pool only when set() creates a new list entry. Replacing an existing entry requires no additional allocation, and the temporary QuickJS string can always be released after the mutation.
xeioex
force-pushed
the
headers-set-validation
branch
from
August 13, 2026 02:16
b2ed5cd to
b458415
Compare
Contributor
Author
|
Applied. |
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.
This is the extended fix for issue reported in #1107