The hosts parser ignores empty lines, but a line containing only whitespace reaches line.split(maxsplit=1) and raises IndexError.
$ printf " \n127.0.0.1 localhost\n" | jc --hosts
jc: Error - hosts parser could not parse the input data.
The module API reproduces the underlying error:
jc.parsers.hosts.parse(" \n127.0.0.1 localhost\n", quiet=True)
# IndexError: list index out of range
Whitespace-only lines should be treated like empty lines and ignored. A strip-aware blank-line filter plus a focused regression test should fix this without changing parsed entries.
The
hostsparser ignores empty lines, but a line containing only whitespace reachesline.split(maxsplit=1)and raisesIndexError.The module API reproduces the underlying error:
Whitespace-only lines should be treated like empty lines and ignored. A strip-aware blank-line filter plus a focused regression test should fix this without changing parsed entries.