- (let ((buf (mm-uu-copy-to-buffer (point-min) (point-max))))
- (if (mm-uu-pgp-encrypted-test)
- (with-current-buffer buf
- (mml2015-clean-buffer)
- (funcall (mml2015-clear-decrypt-function))))
- (list (mm-make-handle buf mm-uu-text-plain-type))))
+ (let ((buf (mm-uu-copy-to-buffer (point-min) (point-max)))
+ (first t)
+ charset)
+ ;; Make sure there's a blank line between header and body.
+ (with-current-buffer buf
+ (goto-char (point-min))
+ (while (prog2
+ (forward-line 1)
+ (if first
+ (looking-at "[^\t\n ]+:")
+ (looking-at "[^\t\n ]+:\\|[\t ]"))
+ (setq first nil)))
+ (unless (memq (char-after) '(?\n nil))
+ (insert "\n"))
+ (save-restriction
+ (narrow-to-region (point-min) (point))
+ (setq charset (mail-fetch-field "charset")))
+ (if (and (mm-uu-pgp-encrypted-test)
+ (progn
+ (mml2015-clean-buffer)
+ (funcall (mml2015-clear-decrypt-function))
+ (equal (mm-handle-multipart-ctl-parameter mm-security-handle
+ 'gnus-info)
+ "OK")))
+ (progn
+ ;; Decode charset.
+ (if (and (or charset
+ (setq charset gnus-newsgroup-charset))
+ (setq charset (mm-charset-to-coding-system charset))
+ (not (eq charset 'ascii)))
+ ;; Assume that buffer's multibyteness is turned off.
+ ;; See `mml2015-pgg-clear-decrypt'.
+ (insert (mm-decode-coding-string (prog1
+ (buffer-string)
+ (erase-buffer)
+ (mm-enable-multibyte))
+ charset))
+ (mm-enable-multibyte))
+ (list (mm-make-handle buf mm-uu-text-plain-type)))
+ (list (mm-make-handle buf '("application/pgp-encrypted")))))))