Repository navigation
fix(http-message-sig): exclude the fragment from the target URI - #200
Conversation
|
This pull request's reviews are posted as pull request reviews: see the review of |
|
@clanky-the-clanker review |
There was a problem hiding this comment.
💬 Approved with comments — The fix is correct and consistent with RFC 9110. The only note is an optional test for descriptors with a non-empty fragment.
Findings: 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 suggestion
The fix is correct for bare and non-empty fragments. There is one optional test suggestion.
Recommendation: 💬 Optional Nits
- [SUGGESTION] Add a descriptor test for a non-empty fragment (and for
@target-uri) (packages/http-message-sig/test/core.spec.ts:326)
View full review
What I checked and found correct:
url.hash = ""clears both a bare#and a non-empty fragment.url.hrefkeeps a trailing?, so@queryis still?.- The fragment is removed before
indexOf("?"), so a?inside a fragment can't be mistaken for the start of the query. nativeis set at both places that build aRequestSnapshot.
Optional: the descriptor rejection path is tested only with a bare # and @path.
✅ All other checks passed
🔒 Security: ✅ LGTM
Descriptor target URIs that contain # are still rejected, and the check is stricter than before because it now catches a bare #. For a native Request, the fragment is stripped once and @target-uri, @path and @query are all derived from that stripped string. The signed values therefore match what fetch actually sends.
📝 Documentation: ✅ LGTM
No documentation problems in the changed lines.
Reviewed commit: 5b029d1c
| ); | ||
| }); | ||
|
|
||
| it("rejects a bare fragment in a descriptor target URI", async () => { |
There was a problem hiding this comment.
💬 SUGGESTION · Code Quality
Add a descriptor test for a non-empty fragment (and for @target-uri)
The only descriptor rejection test uses a bare # with @path. Add a case with https://example.com/path#frag, and one that requests @target-uri. Together they would show that the new includes("#") check rejects non-empty fragments too, and that every derived component goes through it.
|
@konippi good catch. thanks for the fix |
Fixes #194.
The fragment check used
url.hash, which is empty for a bare#, so the#ended up in@target-uri,@pathand@query.RFC 9110 Section 7.1 excludes the fragment from the target URI, so:
Request: the fragment is dropped, as fetch does on the wire.targetUri: any#is rejected, since servers handle a raw#differently.Behavior change: a
Requestwith a fragment now signs without it instead of throwing. Easy to revert if that's not wanted.