diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-10-06 05:26:28 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-10-06 05:26:28 +0800 |
commit | 19d6689653059b95dddabd8a05abf73558138137 (patch) | |
tree | 9ccd6243465ad4f2836309f823e52903a7d73120 | |
parent | 6abc02d6b9260bb8aa191f93d003e5bd8eedd393 (diff) | |
download | gsoc2013-evolution-19d6689653059b95dddabd8a05abf73558138137.tar gsoc2013-evolution-19d6689653059b95dddabd8a05abf73558138137.tar.gz gsoc2013-evolution-19d6689653059b95dddabd8a05abf73558138137.tar.bz2 gsoc2013-evolution-19d6689653059b95dddabd8a05abf73558138137.tar.lz gsoc2013-evolution-19d6689653059b95dddabd8a05abf73558138137.tar.xz gsoc2013-evolution-19d6689653059b95dddabd8a05abf73558138137.tar.zst gsoc2013-evolution-19d6689653059b95dddabd8a05abf73558138137.zip |
Modified to not encode space chars in the middle of a line. (isblank): New
2000-10-05 Jeffrey Stedfast <fejj@helixcode.com>
* camel-mime-utils.c (quoted_encode_step): Modified to not encode
space chars in the middle of a line.
(isblank): New macro if we're not on a system with the GNU isblank
extension.
* camel-mime-message.c (camel_mime_message_set_from): Reversed my
changes, don't header_encode_phrase - it generates broken headers.
(camel_mime_message_set_reply_to): Same.
svn path=/trunk/; revision=5747
-rw-r--r-- | camel/ChangeLog | 11 | ||||
-rw-r--r-- | camel/camel-mime-message.c | 14 | ||||
-rw-r--r-- | camel/camel-mime-utils.c | 68 |
3 files changed, 53 insertions, 40 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index d6c7baa3a8..7d27bba261 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,14 @@ +2000-10-05 Jeffrey Stedfast <fejj@helixcode.com> + + * camel-mime-utils.c (quoted_encode_step): Modified to not encode + space chars in the middle of a line. + (isblank): New macro if we're not on a system with the GNU isblank + extension. + + * camel-mime-message.c (camel_mime_message_set_from): Reversed my + changes, don't header_encode_phrase - it generates broken headers. + (camel_mime_message_set_reply_to): Same. + 2000-10-04 Chris Toshok <toshok@helixcode.com> * providers/nntp/camel-nntp-utils.c (camel_nntp_get_headers): diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 452ddb50ff..690f655ca3 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -239,8 +239,6 @@ camel_mime_message_get_sent_date (CamelMimeMessage *message) void camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, const gchar *reply_to) { - char *text; - g_assert (mime_message); /* FIXME: check format of string, handle it nicer ... */ @@ -248,9 +246,8 @@ camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, const gchar *re g_free (mime_message->reply_to); mime_message->reply_to = g_strstrip (g_strdup (reply_to)); - text = header_encode_phrase (mime_message->reply_to); - CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (mime_message), "Reply-To", text); - g_free (text); + CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (mime_message), "Reply-To", + mime_message->reply_to); } const gchar * @@ -288,8 +285,6 @@ camel_mime_message_get_subject (CamelMimeMessage *mime_message) void camel_mime_message_set_from (CamelMimeMessage *mime_message, const gchar *from) { - char *text; - g_assert (mime_message); /* FIXME: check format of string, handle it nicer ... */ @@ -297,9 +292,8 @@ camel_mime_message_set_from (CamelMimeMessage *mime_message, const gchar *from) g_free (mime_message->from); mime_message->from = g_strstrip (g_strdup (from)); - text = header_encode_phrase (mime_message->from); - CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (mime_message), "From", text); - g_free (text); + CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (mime_message), "From", + mime_message->from); } const gchar * diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index d7136c79f5..5462b6a807 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -140,6 +140,10 @@ enum { #define is_especial(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_ESPECIAL) != 0) #define is_psafe(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_PSAFE) != 0) +#ifndef HAVE_ISBLANK +#define isblank(c) ((c) == ' ' || (c) == '\t') +#endif /* HAVE_ISBLANK */ + /* only needs to be run to rebuild the tables above */ #ifdef BUILD_TABLE @@ -563,70 +567,73 @@ quoted_encode_close(unsigned char *in, int len, unsigned char *out, int *state, } int -quoted_encode_step(unsigned char *in, int len, unsigned char *out, int *statep, int *save) +quoted_encode_step (unsigned char *in, int len, unsigned char *out, int *statep, int *save) { - register unsigned char *inptr, *outptr, *inend; - unsigned char c; - register int sofar = *save, /* keeps track of how many chars on a line */ - last=*statep; /* keeps track if last char to end was a space cr etc */ - + register guchar *inptr, *outptr, *inend; + guchar c; + register int sofar = *save; /* keeps track of how many chars on a line */ + register int last = *statep; /* keeps track if last char to end was a space cr etc */ + inptr = in; - inend = in+len; + inend = in + len; outptr = out; - while (inptr<inend) { + while (inptr < inend) { c = *inptr++; - if (c=='\r') { + if (c == '\r') { if (last != -1) { *outptr++ = '='; - *outptr++ = tohex[(last>>4) & 0xf]; + *outptr++ = tohex[(last >> 4) & 0xf]; *outptr++ = tohex[last & 0xf]; - sofar+=3; + sofar += 3; } last = c; - } else if (c=='\n') { - if (last != -1 && last!='\r') { + } else if (c == '\n') { + if (last != -1 && last != '\r') { *outptr++ = '='; - *outptr++ = tohex[(last>>4) & 0xf]; + *outptr++ = tohex[(last >> 4) & 0xf]; *outptr++ = tohex[last & 0xf]; } *outptr++ = '\n'; - sofar=0; + sofar = 0; last = -1; } else { if (last != -1) { - if (is_qpsafe(last)) { + if (is_qpsafe (last) || isblank (last)) { *outptr++ = last; sofar++; } else { *outptr++ = '='; - *outptr++ = tohex[(last>>4) & 0xf]; + *outptr++ = tohex[(last >> 4) & 0xf]; *outptr++ = tohex[last & 0xf]; - sofar+=3; + sofar += 3; } } - if (is_qpsafe(c)) { - if (sofar>74) { - *outptr++='='; - *outptr++='\n'; + + if (is_qpsafe (c) || isblank (c)) { + if (sofar > 74) { + *outptr++ = '='; + *outptr++ = '\n'; sofar = 0; } - /* delay output of space */ - if (c==' ' || c==0x09) { + + /* delay output of space char */ + if (isblank (c)) { last = c; } else { - *outptr++=c; + *outptr++ = c; sofar++; last = -1; } } else { - if (sofar>72) { - *outptr++='='; - *outptr++='\n'; + if (sofar > 72) { + *outptr++ = '='; + *outptr++ = '\n'; sofar = 3; } else sofar += 3; + *outptr++ = '='; - *outptr++ = tohex[(c>>4) & 0xf]; + *outptr++ = tohex[(c >> 4) & 0xf]; *outptr++ = tohex[c & 0xf]; last = -1; } @@ -634,7 +641,8 @@ quoted_encode_step(unsigned char *in, int len, unsigned char *out, int *statep, } *save = sofar; *statep = last; - return outptr-out; + + return (outptr - out); } /* |