From e9c609d85c53f5a03a08942d65432bb7880b28ed Mon Sep 17 00:00:00 2001 From: piaip Date: Wed, 16 Apr 2008 09:30:51 +0000 Subject: - reduce unnecessary QP encode in mail subject header. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4172 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/outmail.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/util/outmail.c b/util/outmail.c index eb674890..4cf161d9 100644 --- a/util/outmail.c +++ b/util/outmail.c @@ -66,6 +66,16 @@ void disconnectMailServer(int sock) { close(sock); } +int need_qp(const char *_s) +{ + const unsigned char *s = (const unsigned char*)_s; + + while (*s && *s++ < 0x80); + if (*s) + return 1; + return 0; +} + void doSendBody(int sock, FILE *fp, char *from, char *to, char *subject) { int n; char buf[2048]; @@ -86,7 +96,8 @@ void doSendBody(int sock, FILE *fp, char *from, char *to, char *subject) { "Message-Id: <%d.%x.outmail@" MYHOSTNAME ">\r\n" "X-Disclaimer: %s\r\n\r\n", from, from, to, - qp_encode(subject_qp, sizeof(subject_qp), subject, "big5"), + need_qp(subject) ? + qp_encode(subject_qp, sizeof(subject_qp), subject, "big5") : subject, starttime, (msgid += (int)(random() >> 24)), disclaimer); -- cgit v1.2.3