Skip to content

fix(nntp): support open-ended OVER/XOVER ranges ("n-")#66

Closed
johnanleitner1-Coder wants to merge 1 commit into
profullstack:mainfrom
johnanleitner1-Coder:fix/nntp-open-ended-range
Closed

fix(nntp): support open-ended OVER/XOVER ranges ("n-")#66
johnanleitner1-Coder wants to merge 1 commit into
profullstack:mainfrom
johnanleitner1-Coder:fix/nntp-open-ended-range

Conversation

@johnanleitner1-Coder

Copy link
Copy Markdown

Fixes #65.

Problem

parseRange rejected the open-ended range low- (e.g. OVER 5-) as malformed, returning an empty (0, 0) range. So OVER/XOVER with a trailing-dash range returned no articles instead of all articles >= low.

RFC 3977 ranges come in three forms: number, number- (open-ended, through the highest article), and number-number. The earlier "reject malformed OVER ranges" hardening (#45/#46) accidentally swept up the valid number- form along with the genuinely malformed ones.

Fix

Tests

Extended range_test.go with cases for closed (5-10), open-ended (5-), empty ("" = all), and malformed (abc, 5-abc, abc-5, 1-2-3, -, -5) specs.

Note on verification

I don't have a Go 1.26 toolchain in my environment, so I verified the logic by hand-tracing every test case against the new code rather than running go test. The change is a small, pure-function edit using only already-imported packages (math, strconv, strings); please run CI / go test ./internal/news/nntpd/ to confirm. Happy to adjust if you'd prefer a different shape (e.g. capping the upper bound to the group's real high-water mark inside handleOver instead of MaxInt64).

parseRange treated a range of the form "low-" (low article to the
highest available) as malformed and returned an empty (0,0) range, so
OVER/XOVER "n-" returned no articles instead of every article >= n.
RFC 3977 defines a range as a single number, "number-", or
"number-number"; the open-ended form is common in real NNTP clients.

Handle "low-" as (low, MaxInt64), reject specs with more than one dash
(e.g. "1-2-3") as malformed, and keep existing malformed handling so a
bad range still yields an empty range rather than "all articles".
Adds tests for closed, open-ended, empty, and malformed specs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NNTP: OVER/XOVER open-ended range "n-" returns no articles (valid RFC 3977 range rejected as malformed)

1 participant