X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=rfc3676.c;h=b76108daaffac4cfe365289b1f63fb4e6a334cce;hb=a739d748184bb73b17cb8bb97cea4cdeaff0d859;hp=9efa39d364d32171ef12583fe8b670d7bd46fae4;hpb=618ceafdc9564dbb8f3bf45c3869297a1d5a3320;p=apps%2Fmadmutt.git diff --git a/rfc3676.c b/rfc3676.c index 9efa39d..b76108d 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -52,7 +52,7 @@ static void print_flowed_line (char *line, STATE * s, if (MaxLineLength > 0) { width = MaxLineLength - WrapMargin - ql - 1; - if (option (OPTSTUFFQUOTED)) + if (!(s->flags & M_REPLYING) && option (OPTSTUFFQUOTED)) --width; if (width < 0) width = MaxLineLength; @@ -63,7 +63,7 @@ static void print_flowed_line (char *line, STATE * s, else width = COLS - WrapMargin - ql - 1; - if (option (OPTSTUFFQUOTED)) + if (!(s->flags & M_REPLYING) && option (OPTSTUFFQUOTED)) --width; if (width < 0) width = COLS; @@ -74,7 +74,7 @@ static void print_flowed_line (char *line, STATE * s, if (s->prefix) state_puts(s->prefix,s); for (i=0;i',s); - if (option(OPTSTUFFQUOTED)) + if (!(s->flags & M_REPLYING) && option(OPTSTUFFQUOTED)) state_putc(' ',s); } state_putc('\n',s); @@ -123,7 +123,8 @@ static void print_flowed_line (char *line, STATE * s, for (i = 0; i < ql; ++i) state_putc ('>', s); - if (option (OPTSTUFFQUOTED) && (ql > 0 || s->prefix)) + if (!(s->flags & M_REPLYING) && option (OPTSTUFFQUOTED) && + (ql > 0 || s->prefix)) state_putc (' ', s); if (delsp && spaces && space_len > 0) { @@ -270,8 +271,52 @@ void rfc3676_quote_line (STATE* s, char* dst, size_t dstlen, } debug_print (4, ("f=f: quotelevel = %d, new prefix = '%s'\n", i, NONULL (quote))); - /* if we changed prefix, make sure we respect $stuff_quoted */ - snprintf (dst, dstlen, "%s%s%s%s", NONULL (s->prefix), NONULL (quote), - option (OPTSTUFFQUOTED) && line[offset] != ' ' ? " " : "", + snprintf (dst, dstlen, "%s%s%s", NONULL (s->prefix), NONULL (quote), &line[offset]); } + +void rfc3676_space_stuff (HEADER* hdr) { +#if DEBUG + int lc = 0; + size_t len = 0; + unsigned char c = '\0'; +#endif + FILE* in = NULL, *out = NULL; + char buf[LONG_STRING]; + char tmpfile[_POSIX_PATH_MAX]; + + if (!hdr || !hdr->content || !hdr->content->filename) + return; + + debug_print (2, ("f=f: postprocess %s\n", hdr->content->filename)); + if ((in = safe_fopen (hdr->content->filename, "r")) == NULL) + return; + mutt_mktemp (tmpfile); + if ((out = safe_fopen (tmpfile, "w+")) == NULL) { + fclose (in); + return; + } + + while (fgets (buf, sizeof (buf), in)) { + if (ascii_strncmp ("From ", buf, 4) == 0 || buf[0] == ' ') { + fputc (' ', out); +#if DEBUG + lc++; + len = str_len (buf); + if (len > 0) { + c = buf[len-1]; + buf[len-1] = '\0'; + } + debug_print (4, ("f=f: line %d needs space-stuffing: '%s'\n", + lc, buf)); + if (len > 0) + buf[len-1] = c; +#endif + } + fputs (buf, out); + } + fclose (in); + unlink (hdr->content->filename); + fclose (out); + str_replace (&hdr->content->filename, tmpfile); +}