X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/6e3b198d9efa70de98409fbb78b9f83257b2101c..8d468c4c169a7519d5b172cc049b1d8cc7b1c343:/src/src/sieve.c diff --git a/src/src/sieve.c b/src/src/sieve.c index bda482fd1..8f98aebab 100644 --- a/src/src/sieve.c +++ b/src/src/sieve.c @@ -232,6 +232,9 @@ uschar *new = NULL; uschar ch; size_t line; +/* Two passes: one to count output allocation size, second +to do the encoding */ + for (pass=0; pass<=1; ++pass) { line=0; @@ -245,54 +248,47 @@ for (pass=0; pass<=1; ++pass) for (start=src->character,end=start+src->length; start=73) + if (line>=73) /* line length limit */ { if (pass==0) dst->length+=2; else { - *new++='='; + *new++='='; /* line split */ *new++='\n'; } line=0; } - if - ( - (ch>=33 && ch<=60) - || (ch>=62 && ch<=126) - || - ( - (ch==9 || ch==32) - && start+2='!' && ch<='<') + || (ch>='>' && ch<='~') + || ( (ch=='\t' || ch==' ') + && start+2length; else - *new++=*start; + *new++=*start; /* copy char */ ++line; } - else if (ch=='\r' && start+1length; - line=0; - } else - *new++='\n'; - line=0; /*XXX jgh: questionabale indent; probable BUG */ - ++start; + *new++='\n'; /* NL */ + line=0; + ++start; /* consume extra input char */ } else { if (pass==0) dst->length+=3; else - { - sprintf(CS new,"=%02X",ch); + { /* encoded char */ + new += sprintf(CS new,"=%02X",ch); new+=3; } line+=3;