fix(nntpd): support open-ended NNTP ranges in XOVER/OVER#74
Closed
AliaksandrNazaruk wants to merge 1 commit into
Closed
fix(nntpd): support open-ended NNTP ranges in XOVER/OVER#74AliaksandrNazaruk wants to merge 1 commit into
AliaksandrNazaruk wants to merge 1 commit into
Conversation
parseRange split the spec on '-' and required BOTH bounds to parse as
integers. For a valid open-ended range like '5-' (RFC 3977 6.2.3 / RFC 2980
XOVER: article 5 through the last) strconv.ParseInt('') fails, so parseRange
returned (0, 0) and handleOver asked the backend for articles in [0, 0] —
zero rows. '-10' (first..10) was likewise broken.
Treat an empty bound as the extreme (low 0 / high MaxInt64) while still
returning an empty range for genuinely malformed specs. Add table-driven
tests for the open-ended and malformed forms.
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.
Problem
parseRange(internal/news/nntpd/server.go) split the spec on-and required both bounds to parse as integers. For a valid open-ended NNTP range like"5-"(RFC 3977 §6.2.3 / RFC 2980XOVER: article 5 through the last),strconv.ParseInt("")fails, soparseRangereturned(0, 0)andhandleOverasked the backend for[0, 0]— zero rows."-10"(first..10) was broken the same way.Fix
Parse each bound independently and treat an empty bound as the extreme (
low = 0,high = math.MaxInt64), while still returning(0, 0)for genuinely malformed specs:"5"→(5, 5)"5-10"→(5, 10)"5-"→(5, MaxInt64)"-10"→(0, 10)""→(0, MaxInt64)"abc","5-abc","abc-10"→(0, 0)math,strconv,stringswere already imported. AddedTestParseRange(table-driven) covering the open-ended and malformed forms alongside the existing single-article test.Fixes #73.