about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mmime.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mmime.c b/mmime.c
index 2f0636a..7d47a20 100644
--- a/mmime.c
+++ b/mmime.c
@@ -312,6 +312,7 @@ print_header(char *line) {
 	}
 
 	int prevq = 0;  // was the previous word encoded as qp?
+	char prevqs = 0;  // was the previous word a quoted-string?
 
 	ssize_t linelen = s - line;
 
@@ -354,7 +355,7 @@ print_header(char *line) {
 				// space at beginning of line
 				goto force_qp;
 			}
-			if (*s != ' ') {
+			if (*s != ' ' && !(prevqs && !prevq && *(s-1) != ' ')) {
 				printf(" ");
 				linelen++;
 			}
@@ -388,6 +389,7 @@ force_qp:
 			if (qs && *e == '"')
 				e++;
 		}
+		prevqs = qs;
 		s = e;
 	}
 	printf("\n");