From: Michael Vrable Date: Thu, 16 Aug 2007 03:09:42 +0000 (-0700) Subject: Fix RFC 3676 (format=flowed text) handling. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc01f69aa31db8d9b2400587c9cf684efe1c51c0;p=neomutt Fix RFC 3676 (format=flowed text) handling. The old code would consider a line containing "> " to be flowed, but since this is a quoted and space-stuffed line containing no additional text, by my reading of RFC 3676 it should be fixed. Clean up the handling of format=flowed text. Fix the test to determine whether a line is fixed--if a line ends in a space only because the last character is a space from space-stuffing, consider the line to be a fixed line. This makes the test for ((buf_len - buf_off) <= 0) later no longer necessary. Also simplify the code by removing checks for curline being non-null; it is allocated at the start of the function and never reallocated to size zero, so it should never be a null pointer. --- diff --git a/rfc3676.c b/rfc3676.c index d6b0bad49..9ccb32727 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -172,7 +172,7 @@ int rfc3676_handler (BODY * a, STATE * s) /* a change of quoting level in a paragraph - shouldn't happen, * but has to be handled - see RFC 3676, sec. 4.5. */ - if (newql != quotelevel && curline && *curline) + if (newql != quotelevel && *curline) { print_flowed_line (curline, s, quotelevel); *curline = '\0'; @@ -202,25 +202,14 @@ int rfc3676_handler (BODY * a, STATE * s) /* a fixed line either has no trailing space or is the * signature separator */ - fixed = buf_len == 0 || buf[buf_len - 1] != ' ' || sigsep; + fixed = buf_len == buf_off || buf[buf_len - 1] != ' ' || sigsep; - /* for DelSp=yes, we need to strip one SP prior to CRLF; - * in case of the signature separator, leave the space */ - if (delsp && !sigsep && buf_len >= 1 && buf[buf_len-1] == ' ') + /* for DelSp=yes, we need to strip one SP prior to CRLF on flowed lines */ + if (delsp && !fixed) buf[--buf_len] = '\0'; - /* we're here when last space removed because of DelSp was - * the last space and there isn't more -> done */ - if ((buf_len - buf_off) <= 0) - { - print_flowed_line (curline, s, quotelevel); - *curline = '\0'; - curline_len = 1; - continue; - } - /* signature separator also flushes the previous paragraph */ - if (sigsep && curline && *curline) + if (sigsep && *curline) { print_flowed_line (curline, s, quotelevel); *curline = '\0';