diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-16 17:30:51 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-16 17:30:51 +0800 |
commit | e9c609d85c53f5a03a08942d65432bb7880b28ed (patch) | |
tree | c88faa85d97c8266a596cd30bd190a67635773ee | |
parent | e945ea798cc53053365fc9aa302ec027705c4154 (diff) | |
download | pttbbs-e9c609d85c53f5a03a08942d65432bb7880b28ed.tar pttbbs-e9c609d85c53f5a03a08942d65432bb7880b28ed.tar.gz pttbbs-e9c609d85c53f5a03a08942d65432bb7880b28ed.tar.bz2 pttbbs-e9c609d85c53f5a03a08942d65432bb7880b28ed.tar.lz pttbbs-e9c609d85c53f5a03a08942d65432bb7880b28ed.tar.xz pttbbs-e9c609d85c53f5a03a08942d65432bb7880b28ed.tar.zst pttbbs-e9c609d85c53f5a03a08942d65432bb7880b28ed.zip |
- reduce unnecessary QP encode in mail subject header.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4172 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | util/outmail.c | 13 |
1 files changed, 12 insertions, 1 deletions
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); |