#742·jc

hosts parser crashes on whitespace-only lines

Author: tunglambkCreated Aug 26, 2026Updated Aug 26, 2026
Labelsbugready-to-ship

The hosts parser ignores empty lines, but a line containing only whitespace reaches line.split(maxsplit=1) and raises IndexError.

bash
$ 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:

python
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.