Skip to content

hosts parser crashes on whitespace-only lines #742

Description

@tunglambk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions