[PATCH 3/6] Convert pgp_sign_message() to perform textmode handling.

"Kevin J. McCarthy" <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <[email protected]>
---
 pgp.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/pgp.c b/pgp.c
index 5d3ef3f3..0d485cd2 100644
--- a/pgp.c
+++ b/pgp.c
@@ -1238,13 +1238,14 @@ BODY *pgp_sign_message (BODY *a)
 {
   BODY *t, *rv = NULL;
   char buffer[LONG_STRING];
-  BUFFER *sigfile, *signedfile;
+  BUFFER *sigfile, *lf_file, *signedfile;
   FILE *pgpin, *pgpout, *pgperr, *fp, *sfp;
   int err = 0;
   int empty = 1;
   pid_t thepid;
 
   sigfile = mutt_buffer_pool_get ();
+  lf_file = mutt_buffer_pool_get ();
   signedfile = mutt_buffer_pool_get ();
 
   convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */
@@ -1255,10 +1256,10 @@ BODY *pgp_sign_message (BODY *a)
     goto cleanup;
   }
 
-  mutt_buffer_mktemp (signedfile);
-  if ((sfp = safe_fopen (mutt_b2s (signedfile), "w")) == NULL)
+  mutt_buffer_mktemp (lf_file);
+  if ((sfp = safe_fopen (mutt_b2s (lf_file), "w")) == NULL)
   {
-    mutt_perror (mutt_b2s (signedfile));
+    mutt_perror (mutt_b2s (lf_file));
     safe_fclose (&fp);
     unlink (mutt_b2s (sigfile));
     goto cleanup;
@@ -1269,6 +1270,16 @@ BODY *pgp_sign_message (BODY *a)
   mutt_write_mime_body (a, sfp);
   safe_fclose (&sfp);
 
+  mutt_buffer_mktemp (signedfile);
+  if (mutt_convert_to_crlf (mutt_b2s (lf_file), NULL, mutt_b2s (signedfile), NULL) < 0)
+  {
+    safe_fclose (&fp);
+    unlink (mutt_b2s (sigfile));
+    unlink (mutt_b2s (lf_file));
+    goto cleanup;
+  }
+  unlink (mutt_b2s (lf_file));
+
   if ((thepid = pgp_invoke_sign (&pgpin, &pgpout, &pgperr,
                                  -1, -1, -1, mutt_b2s (signedfile))) == -1)
   {
@@ -1357,6 +1368,7 @@ BODY *pgp_sign_message (BODY *a)
 
 cleanup:
   mutt_buffer_pool_release (&sigfile);
+  mutt_buffer_pool_release (&lf_file);
   mutt_buffer_pool_release (&signedfile);
   return (rv);
 }
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.