summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--notemap.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/notemap.c b/notemap.c
index 35dba0c..f1ebf5a 100644
--- a/notemap.c
+++ b/notemap.c
@@ -217,6 +217,12 @@ static void append(
 		localtime(&status.st_mtime)
 	);
 
+	char subj[78 - (sizeof("Subject: ") - 1)] = {0};
+	for (size_t i = 0; i < sizeof(subj) - 1; ++i) {
+		if (!path[i]) break;
+		subj[i] = (path[i] & 0x80 ? '?' : path[i]);
+	}
+
 #define HEADERS \
 	"From: <%s>\r\n" \
 	"Subject: %s\r\n" \
@@ -231,7 +237,7 @@ static void append(
 
 	size_t max = sizeof(HEADERS)
 		+ strlen(from)
-		+ strlen(path)
+		+ strlen(subj)
 		+ strlen(date)
 		+ strlen(uuid)
 		+ 3 * status.st_size
@@ -241,7 +247,7 @@ static void append(
 
 	FILE *msg = fmemopen(buf, max, "w");
 	if (!msg) err(EX_OSERR, "fmemopen");
-	fprintf(msg, HEADERS, from, path, date, uuid);
+	fprintf(msg, HEADERS, from, subj, date, uuid);
 #undef HEADERS
 
 	int ch;