Repository navigation
Reject inverted single-byte Range like bytes=5-4 - #3389
Merged
Kludex merged 3 commits intoAug 8, 2026
Merged
Conversation
_parse_range_header only rejected ranges where start > end, but "bytes=5-4" parses to the empty half-open range (5, 5), which slips past that guard and produces a malformed 206 response (Content-Length 0, a backwards Content-Range) instead of a 400. Reject empty ranges with start >= end; a genuine one-byte request like "bytes=5-5" parses to (5, 6) and is unaffected. Adds tests for the inverted range (400) and the valid one-byte range (206).
Kludex
marked this pull request as ready for review
August 8, 2026 08:53
Kludex
approved these changes
Aug 8, 2026
Kludex
enabled auto-merge (squash)
August 8, 2026 08:55
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.
Summary
Closes #3388.
FileResponse._parse_range_headeronly rejected ranges wherestart > end, butbytes=5-4parses to the empty half-open range(5, 5)and slipped past that guard, producing a malformed206(Content-Length: 0, a backwardsContent-Range) instead of a400.bytes=10-5was already caught (it parses to(10, 6)); the missed case is the off-by-one boundary whereend + 1 == start.The guard is now
start >= end. A genuine one-byte requestbytes=5-5parses to(5, 6)and is unaffected.Checklist