Skip to content

fix(nntpd): support open-ended NNTP ranges in XOVER/OVER#74

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

fix(nntpd): support open-ended NNTP ranges in XOVER/OVER#74
AliaksandrNazaruk wants to merge 1 commit into
profullstack:mainfrom
AliaksandrNazaruk:fix/nntp-open-ended-range

Conversation

@AliaksandrNazaruk

Copy link
Copy Markdown

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 2980 XOVER: article 5 through the last), strconv.ParseInt("") fails, so parseRange returned (0, 0) and handleOver asked 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, strings were already imported. Added TestParseRange (table-driven) covering the open-ended and malformed forms alongside the existing single-article test.

Fixes #73.

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.
@ralyodio ralyodio closed this Jul 3, 2026
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 open-ended range ("5-") parsed as empty range — XOVER/OVER return no articles

2 participants