Only convert LF to CRLF when encrypting with S/MIME

When only signing with S/MIME, `message-encode-message-body` complained about
not being able to find \n\n.  However, we only need the conversion when
encrypting with S/MIME, and apparently the LF → CRLF conversion hack is working
in that case.

However, I think there should be some way to fix this properly within Gnus,
maybe via some configuration … I think I have to write to the Gnus Usenet group
for this.
This commit is contained in:
Daniel - 2021-04-05 15:11:44 +02:00
parent b0a3808973
commit 5348856628
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 15 additions and 3 deletions

18
init.el
View File

@ -1750,11 +1750,23 @@
:config (progn
;; Outlook seems to expect \r\n in PKCS#7 encrypted containers, but
;; Gnus is only sending \n; so let's artificially replace \n by \r\n
;; after, well, signing? Seems to work at least in the case where
;; we are sending S/MIME encrypted and signed messages.
;; after, well, signing? But only if we are encrypting with S/MIME,
;; as otherwise the search for \n\n in `message-encode-message-body'
;; will break. However, I think this is not the right way to do it
;; … isn't there some way to specify the encoding of the the
;; relevant MML buffers to be some nasty cp1252 or something?
;; A previous version of this worked, but the following has not been
;; tested with Outlook proper.
(defun db/smime-add-crlf-when-pkcs7 (cont)
"If CONT signifies encryption with smime, replace all \n with \r\n."
(when (and (eq (car cont) 'part)
(string= "smime" (or (cdr (assq 'encrypt cont)) "")))
(db/convert-lf-to-crlf-in-buffer)))
(advice-add 'mml-smime-epg-sign
:after #'db/convert-lf-to-crlf-in-buffer) ))
:after #'db/smime-add-crlf-when-pkcs7)))
;; Archiving