From b190641eb0b6d2e583d9499ec157c83fb0beae97 Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Thu, 25 Jun 2009 21:46:28 +0200 Subject: [PATCH] Fix f=f corner case with DelSp=yes abuse --- rfc3676.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rfc3676.c b/rfc3676.c index de1683e7b..aadda0f30 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -43,6 +43,7 @@ typedef struct flowed_state { size_t width; size_t spaces; + int delsp; } flowed_state_t; static int get_quote_level (const char *line) @@ -110,6 +111,7 @@ static void print_flowed_line (char *line, STATE *s, int ql, { size_t width, w, words = 0; char *p; + char last; if (!line || !*line) { @@ -121,6 +123,7 @@ static void print_flowed_line (char *line, STATE *s, int ql, } width = quote_width (s, ql); + last = line[mutt_strlen (line) - 1]; dprint (4, (debugfile, "f=f: line [%s], width = %ld, spaces = %d\n", NONULL(line), (long)width, fst->spaces)); @@ -143,8 +146,12 @@ static void print_flowed_line (char *line, STATE *s, int ql, w = mutt_strwidth (p); /* see if we need to break the line but make sure the first - word is put on the line regardless */ - if (w < width && w + fst->width + fst->spaces > width) + word is put on the line regardless; + if for DelSp=yes only one trailing space is used, we probably + have a long word that we should break within (we leave that + up to the pager or user) */ + if (!(!fst->spaces && fst->delsp && last != ' ') && + w < width && w + fst->width + fst->spaces > width) { dprint(4,(debugfile,"f=f: break line at %d, %d spaces left\n", fst->width, fst->spaces)); @@ -199,6 +206,7 @@ int rfc3676_handler (BODY * a, STATE * s) { delsp = mutt_strlen (t) == 3 && ascii_strncasecmp (t, "yes", 3) == 0; t = NULL; + fst.delsp = 1; } dprint (4, (debugfile, "f=f: DelSp: %s\n", delsp ? "yes" : "no")); -- 2.40.0