From 6c0952c1d53bc73b1beefc46ef9ee08cd5213ac3 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Thu, 25 Sep 2014 12:23:19 +0200 Subject: [PATCH] Use trim() to strip whitespace from the end of header fields The main motivation was to ease adding attachments. You'll easy happen to have trailing whitespace there, whereas you'll probably never want to send files that have a name with whitespace at the end ... at least you should never want to have or even send such files. I don't know if it is a good idea to strip the trailing whitespace in `anno -list' as well. I couldn't come up with an example when I would want to keep it, hence I decided to remove it. This can be changed back, if needed. --- man/anno.man1 | 1 + uip/anno.c | 5 +---- uip/send.c | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/man/anno.man1 b/man/anno.man1 index 07bd32c..d545f2d 100644 --- a/man/anno.man1 +++ b/man/anno.man1 @@ -178,6 +178,7 @@ The .B \-list mode produces a listing of the field bodies for header fields with matching component names, one per line. +Trailing whitespace in the field body does not get printed. If the .B \-number option is also used, diff --git a/uip/anno.c b/uip/anno.c index 2647d97..e874238 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -328,10 +328,7 @@ annolist(char *file, unsigned char *comp, int number) if (strncasecmp(field, comp, length)==0 && field[length] == ':') { - for (cp = field + length + 1; - *cp == ' ' || *cp == '\t'; cp++) { - continue; - } + cp = trim(field + length + 1); if (number) { printf("%d\t", count++); } diff --git a/uip/send.c b/uip/send.c index e63074c..bf37600 100644 --- a/uip/send.c +++ b/uip/send.c @@ -425,9 +425,7 @@ attach(char *draft_file_name) while (get_line() != EOF && *field && *field != '-') { if (strncasecmp(field, attach_hdr, length) == 0 && field[length] == ':') { - for (p = field+length+1; *p==' ' || *p=='\t'; p++) { - continue; - } + p = trim(field+length+1); if (*p == '+') { /* forwarded message */ fprintf(composition_file, "#forw [forwarded message(s)] %s\n", p); -- 1.7.10.4