mark/metadata
Manuel Rüger d714bc9d2b fix: move scanner.Err() check after loop and fix matches bounds check
Two bugs in ExtractMeta:

1. scanner.Err() was checked inside the Scan() loop. According to the
   bufio.Scanner docs, Err() returns nil during a successful scan; it
   only reflects an error after Scan() returns false. Moving the check
   after the loop ensures real I/O errors are surfaced instead of
   silently ignored.

2. The len(matches) guard was 'len(matches) > 1' but the code
   accessed matches[2] (requires len >= 3). reHeaderPatternV2 always
   produces a 3-element slice when it matches, but the condition was
   misleading and could panic if the regex were ever changed to make
   the second capture group optional. Changed to 'len(matches) > 2'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-16 19:18:29 +01:00
..