From a0c11b5432eed2d7bfc24f489425b030b5346bfc Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 27 Jan 2020 15:59:46 -0500 Subject: Encode trailing whitespace in quote-printable properly --- notemap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/notemap.c b/notemap.c index 5f35794..c7f116f 100644 --- a/notemap.c +++ b/notemap.c @@ -246,14 +246,14 @@ static void append( int ch; int len = 0; + bool ws = false; while (EOF != (ch = fgetc(note))) { if (len == 76 && ch != '\n') { fprintf(msg, "=\r\n"); len = 0; } if (ch == '\n') { - // TODO: Check if last character was space or tab. - fprintf(msg, "\r\n"); + fprintf(msg, "%s\r\n", (ws ? "=\r\n" : "")); len = 0; } else if (ch == '\t' || (ch >= ' ' && ch <= '~' && ch != '=')) { fprintf(msg, "%c", ch); @@ -262,6 +262,7 @@ static void append( fprintf(msg, "=%02X", ch); len += 3; } + ws = (ch == '\t' || ch == ' '); } if (ferror(note)) err(EX_IOERR, "%s", path); fclose(note); -- cgit 1.4.1