From 8d0a4024b76b7e85c0ccede853fc2cdcceea2afb Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 15 Sep 2026 22:32:35 +0200 Subject: check refuses an empty time format; krino.conf(5) corrected from the re-audit --- internal/engine/engine_test.go | 2 ++ internal/plan/placeholder.go | 3 +++ 2 files changed, 5 insertions(+) (limited to 'internal') diff --git a/internal/engine/engine_test.go b/internal/engine/engine_test.go index 4af8f79..7de2f76 100644 --- a/internal/engine/engine_test.go +++ b/internal/engine/engine_test.go @@ -272,6 +272,8 @@ func TestLoadRefusesBadPlaceholders(t *testing.T) { {`(rename "{0}-x")`, "numbered from 1"}, {`(copy "Out/{10}")`, "unknown placeholder {10}"}, {`(move "Out/{name")`, "unclosed placeholder"}, + {`(move "Out/{mtime:}")`, "needs a format"}, + {`(move "Out/{now:}")`, "needs a format"}, } { h := sandbox(t) os.MkdirAll(filepath.Join(h, "dl"), 0o755) diff --git a/internal/plan/placeholder.go b/internal/plan/placeholder.go index 5922b07..5675e01 100644 --- a/internal/plan/placeholder.go +++ b/internal/plan/placeholder.go @@ -143,6 +143,9 @@ func expandOne(body string, f Facts) (string, error) { // they point at what the config author actually wrote (B3) instead of // hardcoding "mtime" for a {now:...} format error. func strftime(verb, format string, t time.Time) (string, error) { + if format == "" { + return "", fmt.Errorf("{%s:} needs a format, like {%s:%%Y}", verb, verb) + } var b strings.Builder for i := 0; i < len(format); i++ { c := format[i] -- cgit v1.3