Skip to contentSkip to conversation

mailsplit: handle tabs in headers

PATCH New Benjamin LaHaise 1 participant 1 message Apr 1, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mailsplit: handle tabs in headers

Hello Linus et al,

The patch below fixes mailsplit to cope with non-' ' space characters in mail headers. Some people seem to have mail clients that use tabs which would result in mailsplit omitting those headers from its substitutions.

-ben

Signature · 41 lines
"Time is what keeps everything from happening all at once." -- John Wheeler

===== mailsplit.c 1.5 vs edited =====
--- 1.5/mailsplit.c	2002-10-09 15:52:37 -04:00
+++ edited/mailsplit.c	2005-04-01 15:26:54 -05:00
@@ -37,9 +37,9 @@
 	void (*fn)(const char *);
 	char value[HDRLEN];
 } header[] = {
-	{ "From: ", parse_from },
-	{ "Subject: " },
-	{ "Date: " }
+	{ "From:", parse_from },
+	{ "Subject:" },
+	{ "Date:" }
 };
 
 enum header_type { FROM, SUBJECT, DATE, NRHEADERS };
@@ -218,6 +218,12 @@
 			int len = strlen(name);
 			if (memcmp(buffer, name, len))
 				continue;
+			if (!isspace(buffer[len])) {
+				fprintf(stderr,
+					"malformed mail: no space after header\n");
+				continue;
+			}
+			len++;
 			strncpy(header[i].value, buffer+len, HDRLEN-1);
 			if (header[i].fn)
 				header[i].fn(header[i].value);
===== Makefile 1.7 vs edited =====
--- 1.7/Makefile	2003-05-25 22:56:42 -04:00
+++ edited/Makefile	2005-04-01 15:12:42 -05:00
@@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS=-Wall -O2
+CFLAGS=-Wall -g
 HOME=$(shell echo $$HOME)
 
 PROGRAMS=mailsplit diffsplit mkfile bkr