#771·jc

fstab, passwd, group, shadow and gshadow parsers crash on whitespace-only lines

Author: SulimanAbdulrazzaqCreated Sep 22, 2026Updated Sep 22, 2026
Labelsbug

The fstab, passwd, group, shadow and gshadow parsers skip empty lines with list(filter(None, ...)), but a line that contains only spaces or tabs gets through that filter. The parser then splits it into fields and raises IndexError, so the whole input fails to parse. This is the same problem #742 reported for hosts, fixed in #743.

Reproduced on dev (08bcc58):

bash
$ printf ' \t \n/dev/sda1 / ext4 defaults 0 1\n' | jc -q --fstab
jc:  Error - fstab parser could not parse the input data.

With the module API, each parser raises IndexError: list index out of range when a whitespace-only line comes before one valid entry:

Parser Input Line that raises
fstab ' \t \n/dev/sda1 / ext4 defaults 0 1\n' fstab.py:158 fs_spec = line_list[0]
passwd ' \t \njdoe:x:1000:1000:test-user:/home/jdoe:/bin/bash\n' passwd.py:162 output_line['password'] = fields[1]
group ' \t \nwheel:x:10:jdoe\n' group.py:181 output_line['password'] = fields[1]
shadow ' \t \njdoe:!!:18113:0:99999:7:::\n' shadow.py:169 output_line['password'] = fields[1]
gshadow ' \t \nwheel:::jdoe\n' gshadow.py:146 output_line['password'] = fields[1]

A whitespace-only line should be skipped like an empty one, as hosts does since #743.