mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 54435b30b6c9f42d13842927e20c27aa267ef960
parent 7e9a73397bce23b7356b953c74301540fa91f015
Author: Leah Neukirchen <leah@vuxu.org>
Date:   Tue, 19 Sep 2017 16:43:58 +0200

mmime: gen_qp: encode trailing space and tab as =20/=09

See RFC2045 6.7.(3):
> It follows that an octet with decimal value 9 or 32 appearing at the
> end of an encoded line must be represented according to Rule #1.

Prefer this over generating a soft-line break and then a real line break.

Diffstat:
mmime.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/mmime.c b/mmime.c @@ -85,7 +85,6 @@ int gen_qp(uint8_t *s, off_t size, int maxlinelen, int linelen) } if ((s[i] > 126) || - (s[i] < 32 && s[i] != '\n' && s[i] != '\t') || (s[i] == '=')) { printf("=%02X", s[i]); linelen += 3; @@ -99,6 +98,18 @@ int gen_qp(uint8_t *s, off_t size, int maxlinelen, int linelen) putc_unlocked('_', stdout); linelen++; prev = '_'; + } else if (s[i] < 33 && s[i] != '\n') { + if ((s[i] == ' ' || s[i] == '\t') && + i+1 < size && + (s[i+1] != '\n' && s[i+1] != '\r')) { + putc_unlocked(s[i], stdout); + linelen += 1; + prev = s[i]; + } else { + printf("=%02X", s[i]); + linelen += 3; + prev = '_'; + } } else if (s[i] == '\n') { if (prev == ' ' || prev == '\t') puts("=");