mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-08-13 14:27:27 +00:00
fix: reject malformed NNTP OVER ranges instead of returning all articles (#48)
parseRange previously returned (0, MaxInt64) for unparseable input, causing OVER/XOVER to deliver the full article overview instead of returning an empty result. Now returns (0, 0) for any parse error. Fixes #45 Co-authored-by: root <root@vultr.guest>
This commit is contained in:
parent
c0378ece3c
commit
5f9d66e1a7
1 changed files with 6 additions and 4 deletions
|
|
@ -173,15 +173,17 @@ func parseRange(spec string) (low, high int64) {
|
|||
if len(parts) == 1 {
|
||||
h, err := strconv.ParseInt(parts[0], 10, 64)
|
||||
if err != nil {
|
||||
h = math.MaxInt64
|
||||
return 0, h
|
||||
return 0, 0 // malformed — empty range instead of all articles
|
||||
}
|
||||
return h, h
|
||||
}
|
||||
l, _ := strconv.ParseInt(parts[0], 10, 64)
|
||||
l, err := strconv.ParseInt(parts[0], 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0 // malformed — empty range
|
||||
}
|
||||
h, err := strconv.ParseInt(parts[1], 10, 64)
|
||||
if err != nil {
|
||||
h = math.MaxInt64
|
||||
return 0, 0 // malformed — empty range
|
||||
}
|
||||
return l, h
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue