Blob Blame History Raw
---
 handler.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- handler.c
+++ handler.c	2022-01-11 10:41:03.491446992 +0000
@@ -782,7 +782,7 @@ static void enriched_set_flags (const wc
 static int text_enriched_handler (BODY *a, STATE *s)
 {
   enum {
-    TEXT, LANGLE, TAG, BOGUS_TAG, NEWLINE, ST_EOF, DONE
+    TEXT, TEXT_GOTWC, LANGLE, TAG, BOGUS_TAG, NEWLINE, ST_EOF, DONE
   } state = TEXT;
 
   LOFF_T bytes = a->length;
@@ -812,7 +812,7 @@ static int text_enriched_handler (BODY *
   {
     if (state != ST_EOF)
     {
-      if (!bytes || (wc = fgetwc (s->fpin)) == WEOF)
+      if (state != TEXT_GOTWC && (!bytes || (wc = fgetwc (s->fpin)) == WEOF))
 	state = ST_EOF;
       else
 	bytes--;
@@ -820,6 +820,8 @@ static int text_enriched_handler (BODY *
 
     switch (state)
     {
+      case TEXT_GOTWC:
+	state = TEXT;
       case TEXT :
 	switch (wc)
 	{
@@ -881,9 +883,8 @@ static int text_enriched_handler (BODY *
 	  enriched_flush (&stte, 1);
 	else
 	{
-	  ungetwc (wc, s->fpin);
 	  bytes++;
-	  state = TEXT;
+	  state = TEXT_GOTWC;
 	}
 	break;
 
@@ -1588,7 +1589,7 @@ void mutt_decode_attachment (BODY *b, ST
  * strip all trailing spaces to improve interoperability;
  * if $text_flowed is unset, simply verbatim copy input
  */
-static int text_plain_handler (BODY *b, STATE *s)
+static int text_plain_handler (BODY *b __attribute__((unused)), STATE *s)
 {
   char *buf = NULL;
   size_t l = 0, sz = 0;