From 63125d6ee5bb4cbefa2169bc53616b9e826d4868 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 10 Jun 2023 22:58:19 -0700 Subject: [PATCH] Ensure gecos string has at least two fields For a `gecos` string like `,,,`, `clojure.string/split` produces `[]` so `interleave` produces an empty result (it stops on the shortest sequence) and so the `apply assoc` fails with two few arguments. This ensures that the `gecos` string will always produce a non-empty result from the `split` so the rest works. Note that `(split "a,,," #",")` produces `["a"]` -- the empty trailing elements are ignored/dropped. --- src/cc/journeyman/real_name/core.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/journeyman/real_name/core.clj b/src/cc/journeyman/real_name/core.clj index 531f077..7f1f492 100644 --- a/src/cc/journeyman/real_name/core.clj +++ b/src/cc/journeyman/real_name/core.clj @@ -33,7 +33,7 @@ "Process this `gecos` field into a map of its sub-fields. See https://en.wikipedia.org/wiki/Gecos_field" [gecos] - (delimited-record->map gecos #"," [:real-name :address :work-phone :home-phone :other])) + (delimited-record->map (str gecos ",?") #"," [:real-name :address :work-phone :home-phone :other])) (defn process-passwd-line "Process this `line` from a passwd file" @@ -168,4 +168,4 @@ ([] (get-real-name)) ([username] - (get-real-name username))) \ No newline at end of file + (get-real-name username)))