Skip comment lines when parsing the passwd and group files (#728)

Skips comment lines when parsing the `passwd` and `group` files.
This commit is contained in:
Dmitry Kovba authored and GitHub committed 2026-05-08 12:22:20 -07:00
1 parent 03280f3952
commit e9f4ece2bb
1 file changed
+6 -2
+6 -2
View File
@@ -115,10 +115,14 @@ extension User {
let content = try String(contentsOf: file, encoding: .ascii)
let lines = content.components(separatedBy: .newlines)
for line in lines {
guard !line.isEmpty else {
let trimmed = line.trimmingCharacters(in: .whitespaces)
guard !trimmed.isEmpty else {
continue
}
try handler(line.trimmingCharacters(in: .whitespaces))
guard !trimmed.hasPrefix("#") else {
continue
}
try handler(trimmed)
}
}