Handle open-ended byte ranges and empty list members correctly - #328
Open
OskarEichler wants to merge 1 commit into
Open
Handle open-ended byte ranges and empty list members correctly#328OskarEichler wants to merge 1 commit into
OskarEichler wants to merge 1 commit into
Conversation
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
Accept valid open-ended byte ranges starting at zero, ignore empty list members, and serialize 0..-1 as bytes=0-. Keep rejecting a sole zero-length suffix and reject empty exclusive Ruby ranges before decrementing their end.
Reproduction
With
r = Net::HTTP::Get.new('/'),r['Range'] = 'bytes=0-'; r.rangeraises before the patch but returns[0..-1]afterward.r.range = 0..-1previously produced bytes=-0. Parsing bytes=,0-1 or bytes=0-1,,2-3 also raised. Assigning 0...0 previously produced an invalid range.Verification
bundle exec rake test: 201 tests, 914 assertions, zero failures/errors, both baseline and this isolated patch.git diff --checkpass. Supplemental Lint scan retains the same 25 pre-existing findings; no new findings by file/cop.Compatibility and limitations
No API or dependency change. Intentional corrections: these valid inputs now succeed; assigning an empty exclusive range raises Net::HTTPHeaderSyntaxError. Sole bytes=-0 remains rejected.
Based on master
23e859e92e10e43cad520fcacac3fd43640dba7b. Optional external OpenSSL tests and other Ruby/OS combinations were not run. Existing related issues/PRs were checked; this is a focused correctness change, not a claim of exhaustive coverage.Reference: https://www.rfc-editor.org/rfc/rfc9110.html#section-5.6.1.2