diff options
author | Robin Jarry <robin@jarry.cc> | 2023-02-21 17:05:14 +0100 |
---|---|---|
committer | Moritz Poldrack <git@moritz.sh> | 2023-02-22 22:25:56 +0100 |
commit | 1b00f281d98e2cf82e0e6aed91b776c18eb73292 (patch) | |
tree | 6953a42958fc2ea239593de7ad73ca896951fdd4 /config/ui.go | |
parent | 3c898a20d5b147764a4c89bfaebcbc4422a79f37 (diff) | |
download | aerc-1b00f281d98e2cf82e0e6aed91b776c18eb73292.tar.gz |
dirlist: fix conversion of dirlist-format
strings.SplitN is not like python str.split() method... It requires an
exact number of items including the trailing non split part.
Add unit tests to ensure it works.
Fixes: 6cfbc87d8ab0 ("dirlist: use templates instead of % mini language")
Reported-by: John Mcenroy <handplanet@outlook.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Ben Lee-Cohen <ben@lee-cohen.com>
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Diffstat (limited to 'config/ui.go')
-rw-r--r-- | config/ui.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/config/ui.go b/config/ui.go index 599651d1..b1330ffd 100644 --- a/config/ui.go +++ b/config/ui.go @@ -581,12 +581,12 @@ func convertDirlistFormat(format string) (string, string) { return s }, ) - tokens := strings.SplitN(tmpl, "%>", 1) + tokens := strings.SplitN(tmpl, "%>", 2) switch len(tokens) { case 2: - return tokens[0], tokens[1] + return strings.TrimSpace(tokens[0]), strings.TrimSpace(tokens[1]) case 1: - return tokens[0], "" + return strings.TrimSpace(tokens[0]), "" default: return "", "" } |