From 748623e03aea967ef6096543d9e2a6a682c5fd93 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Thu, 7 Sep 2000 21:03:20 +0000 Subject: [PATCH] Detect pure 7bit data and don't encode them. This helps a bit in situations where mutt believes it has some really strange us-ascii alias as the character set. --- rfc2231.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rfc2231.c b/rfc2231.c index 673a2191..f2d01bd5 100644 --- a/rfc2231.c +++ b/rfc2231.c @@ -308,9 +308,20 @@ int rfc2231_encode_string (char **pd) char *charset, *s, *t, *e, *d = 0; size_t slen, dlen = 0; - if (!*pd) + /* + * A shortcut to detect pure 7bit data. + * + * This should prevent the worst when character set handling + * is flawed. + */ + + for (s = *pd; *s; s++) + if (*s & 0x80) + break; + + if (!*s) return 0; - + if (!Charset || !SendCharset || !(charset = mutt_choose_charset (Charset, SendCharset, *pd, strlen (*pd), &d, &dlen))) -- 2.40.0