fix: do not reject open-ended Range values in simpleRangeHeaderValue#5490
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5490 +/- ##
=======================================
Coverage 93.45% 93.46%
=======================================
Files 110 110
Lines 37147 37150 +3
=======================================
+ Hits 34716 34721 +5
+ Misses 2431 2429 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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.
The "simple range header value" parser rejected valid open-ended ranges such
as
bytes=5-.Per https://fetch.spec.whatwg.org/#simple-range-header-value step 18, the
"start greater than end" failure only applies when rangeStartValue and
rangeEndValue are both numbers. For an open-ended range like
bytes=5-,rangeEndValue is null. The code compared
rangeStartValue > rangeEndValuedirectly, and JavaScript coerces null to 0 in that comparison, so
5 > nullbecomes
5 > 0, which is true, and the parser returned failure.The effect is that
fetch()of ablob:URL withRange: bytes=5-returned anetwork error and the promise rejected, instead of returning a 206 Partial
Content.
bytes=0-worked only by accident because 0 does not exceed 0.This change guards the comparison so it runs only when both values are numbers,
matching the spec. A genuinely inverted range such as
bytes=5-3still returnsfailure, and the null-null case is already handled by step 17.
Added a test that fetches a blob URL with
Range: bytes=5-and asserts a 206response with the correct body and Content-Range.