mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-17 07:57:37 +08:00
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>