X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmsgbase.c;h=70b368f29025ef059406699387fd5536ef69ec96;hb=7713fe4c844c81903a7a1a36700117f4e6450d8b;hp=98510111a8ff51f0d365914409b94594c236ad8a;hpb=182f984f6f03067f40a7e01bfa82df95f5605358;p=citadel.git diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 98510111a..70b368f29 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2049,11 +2049,12 @@ START_TEXT: } else if (mode == MT_RFC822) { /* unparsed RFC822 dump */ int eoh = 0; + const char *StartOfText = StrBufNOTNULL; char outbuf[1024]; int outlen = 0; int nllen = strlen(nl); - prev_ch = 0; + prev_ch = '\0'; while (*mptr != '\0') { if (*mptr == '\r') { /* do nothing */ @@ -2065,12 +2066,17 @@ START_TEXT: eoh = (*(mptr+1) == '\r') && (*(mptr+2) == '\n'); if (!eoh) eoh = *(mptr+1) == '\n'; + if (eoh) + { + StartOfText = mptr; + StartOfText = strchr(StartOfText, '\n'); + StartOfText = strchr(StartOfText, '\n'); + } } - - if ( - ((headers_only == HEADERS_NONE) && (eoh)) - || ((headers_only == HEADERS_ONLY) && (!eoh)) - || ((headers_only != HEADERS_NONE) && (headers_only != HEADERS_ONLY)) + if (((headers_only == HEADERS_NONE) && (mptr >= StartOfText)) || + ((headers_only == HEADERS_ONLY) && (mptr < StartOfText)) || + ((headers_only != HEADERS_NONE) && + (headers_only != HEADERS_ONLY)) ) { if (*mptr == '\n') { memcpy(&outbuf[outlen], nl, nllen); @@ -2084,12 +2090,14 @@ START_TEXT: } if (flags & ESC_DOT) { - if ((prev_ch == '\n') && (*mptr == '.') && ((*(mptr+1) == '\r') || (*(mptr+1) == '\n'))) + if ((prev_ch == '\n') && + (*mptr == '.') && + ((*(mptr+1) == '\r') || (*(mptr+1) == '\n'))) { outbuf[outlen++] = '.'; } + prev_ch = *mptr; } - prev_ch = *mptr; ++mptr; if (outlen > 1000) { client_write(outbuf, outlen);