commit 0c2ded6eb803ccb1cf60746a3bb328c04ab5e31e
parent bc4a265e4487004f24804900ab55b2879c45cd01
Author: brookjeynes <me@brookjeynes.dev>
Date: Thu, 11 Jun 2026 14:34:51 +1000
fix: sanitize generated task filenames
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -1,7 +1,7 @@
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
#include <unistd.h>
struct options {
@@ -84,10 +84,14 @@ int main(int argc, char *argv[]) {
}
char title_to_file[256];
+ int in_leading_dots = 1;
for (size_t idx = 0; idx < title_len; idx++) {
- if (cli_args.title[idx] == ' ') {
+ if ((in_leading_dots && cli_args.title[idx] == '.') ||
+ cli_args.title[idx] == ' ' || cli_args.title[idx] == '/' ||
+ cli_args.title[idx] == '\\') {
title_to_file[idx] = '_';
} else {
+ in_leading_dots = 0;
title_to_file[idx] = cli_args.title[idx];
}
}