diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-07-13 12:02:13 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-07-13 12:02:13 +0800 |
commit | 0fcc4e0a670dfc238ea7412cdb61202a07f6a8ea (patch) | |
tree | 01bde9fcf72b84c69636f2dafbaa8f31ecfe4252 /camel | |
parent | 548fa4f72a68b3c47034efcc98a4e573d53f91a7 (diff) | |
download | gsoc2013-evolution-0fcc4e0a670dfc238ea7412cdb61202a07f6a8ea.tar gsoc2013-evolution-0fcc4e0a670dfc238ea7412cdb61202a07f6a8ea.tar.gz gsoc2013-evolution-0fcc4e0a670dfc238ea7412cdb61202a07f6a8ea.tar.bz2 gsoc2013-evolution-0fcc4e0a670dfc238ea7412cdb61202a07f6a8ea.tar.lz gsoc2013-evolution-0fcc4e0a670dfc238ea7412cdb61202a07f6a8ea.tar.xz gsoc2013-evolution-0fcc4e0a670dfc238ea7412cdb61202a07f6a8ea.tar.zst gsoc2013-evolution-0fcc4e0a670dfc238ea7412cdb61202a07f6a8ea.zip |
Reset filter on setup. (reset): When resetting qp encoding, set the state
2000-07-13 Not Zed <NotZed@HelixCode.com>
* camel-mime-filter-basic.c (camel_mime_filter_basic_new_type):
Reset filter on setup.
(reset): When resetting qp encoding, set the state to -1, instead
of 0.
* camel-mime-utils.c (quoted_encode_step): Actually count the
characters output sofar (it never counted any). Bunch of other
fixes.
(quoted_encode_close): Also flush out final character, if ther's
one.
svn path=/trunk/; revision=4135
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 13 | ||||
-rw-r--r-- | camel/camel-mime-filter-basic.c | 9 | ||||
-rw-r--r-- | camel/camel-mime-utils.c | 98 |
3 files changed, 96 insertions, 24 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 3086a3410e..6f01dbbd19 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,16 @@ +2000-07-13 Not Zed <NotZed@HelixCode.com> + + * camel-mime-filter-basic.c (camel_mime_filter_basic_new_type): + Reset filter on setup. + (reset): When resetting qp encoding, set the state to -1, instead + of 0. + + * camel-mime-utils.c (quoted_encode_step): Actually count the + characters output sofar (it never counted any). Bunch of other + fixes. + (quoted_encode_close): Also flush out final character, if ther's + one. + 2000-07-12 Jeffrey Stedfast <fejj@helixcode.com> Chris forgot to add #include <e-util/e-util.h> to the source files diff --git a/camel/camel-mime-filter-basic.c b/camel/camel-mime-filter-basic.c index 60566abf4e..082fa209ad 100644 --- a/camel/camel-mime-filter-basic.c +++ b/camel/camel-mime-filter-basic.c @@ -67,7 +67,13 @@ reset(CamelMimeFilter *mf) { CamelMimeFilterBasic *f = (CamelMimeFilterBasic *)mf; - f->state = 0; + switch(f->type) { + case CAMEL_MIME_FILTER_BASIC_QP_ENC: + f->state = -1; + break; + default: + f->state = 0; + } f->save = 0; } @@ -214,6 +220,7 @@ camel_mime_filter_basic_new_type(CamelMimeFilterBasicType type) new = NULL; break; } + camel_mime_filter_reset((CamelMimeFilter *)new); return new; } diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index dbf4e4bfc3..46825a952e 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2000 Helix Code Inc. - * + * this is a line ending in spaces + * and this line only contains spaces no tabs * Authors: Michael Zucchi <notzed@helixcode.com> * Jeffrey Stedfast <fejj@helixcode.com> * @@ -509,55 +510,106 @@ int quoted_encode_close(unsigned char *in, int len, unsigned char *out, int *state, int *save) { register unsigned char *outptr = out; + int last; if (len>0) outptr += quoted_encode_step(in, len, outptr, state, save); + last = *state; + if (last != -1) { + /* space/tab must be encoded if its the last character on + the line */ + if (is_qpsafe(last) && last!=' ' && last!=9) { + *outptr++ = last; + } else { + *outptr++ = '='; + *outptr++ = tohex[(last>>4) & 0xf]; + *outptr++ = tohex[last & 0xf]; + } + } + /* hmm, not sure if this should really be added here, we dont want to add it to the content, afterall ...? */ *outptr++ = '\n'; *save = 0; - *state = 0; + *state = -1; return outptr-out; } -/* - FIXME: does not handle trailing spaces/tabs before end of line -*/ int -quoted_encode_step(unsigned char *in, int len, unsigned char *out, int *state, 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 = *state; + unsigned char c=0x100; + 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 */ inptr = in; inend = in+len; outptr = out; while (inptr<inend) { c = *inptr++; - if (is_qpsafe(c)) { - /* check for soft line-break */ - if ((++sofar)>74) { - *outptr++='='; - *outptr++='\n'; - sofar = 1; + if (c=='\r') { + if (last != -1) { + *outptr++ = '='; + *outptr++ = tohex[(last>>4) & 0xf]; + *outptr++ = tohex[last & 0xf]; + sofar+=3; } - *outptr++=c; + last = c; + } else if (c=='\n') { + if (last != -1 && last!='\r') { + *outptr++ = '='; + *outptr++ = tohex[(last>>4) & 0xf]; + *outptr++ = tohex[last & 0xf]; + } + *outptr++ = '\n'; + sofar=0; + last = -1; } else { - if ((++sofar)>72) { - *outptr++='='; - *outptr++='\n'; - sofar = 3; + if (last != -1) { + if (is_qpsafe(last)) { + *outptr++ = last; + sofar++; + } else { + *outptr++ = '='; + *outptr++ = tohex[(last>>4) & 0xf]; + *outptr++ = tohex[last & 0xf]; + sofar+=3; + } + } + if (is_qpsafe(c)) { + if (sofar>74) { + *outptr++='='; + *outptr++='\n'; + sofar = 0; + } + /* delay output of space */ + if (c==' ' || c==0x09) { + last = c; + } else { + *outptr++=c; + sofar++; + last = -1; + } + } else { + if (sofar>72) { + *outptr++='='; + *outptr++='\n'; + sofar = 3; + } else + sofar += 3; + *outptr++ = '='; + *outptr++ = tohex[(c>>4) & 0xf]; + *outptr++ = tohex[c & 0xf]; + last = -1; } - *outptr++ = '='; - *outptr++ = tohex[(c>>4) & 0xf]; - *outptr++ = tohex[c & 0xf]; } } - *state = sofar; + *save = sofar; + *statep = last; return outptr-out; } |