mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-08-14 06:47:28 +00:00
fix(nntp): support open-ended OVER/XOVER ranges ("n-")
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>
This commit is contained in:
parent
105ff0ed8a
commit
c947fd9bf5
2 changed files with 48 additions and 1 deletions
|
|
@ -177,10 +177,19 @@ func parseRange(spec string) (low, high int64) {
|
|||
}
|
||||
return h, h
|
||||
}
|
||||
if len(parts) != 2 {
|
||||
return 0, 0 // malformed (e.g. "1-2-3") — empty range
|
||||
}
|
||||
l, err := strconv.ParseInt(parts[0], 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0 // malformed — empty range
|
||||
}
|
||||
// Open-ended range "low-" means "from low to the highest article"
|
||||
// (RFC 3977: a range is a single number, "number-", or
|
||||
// "number-number"). An empty upper bound is unbounded, not malformed.
|
||||
if parts[1] == "" {
|
||||
return l, math.MaxInt64
|
||||
}
|
||||
h, err := strconv.ParseInt(parts[1], 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0 // malformed — empty range
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue