Synch to Oort Gnus 200304162310.
[elisp/gnus.git-] / lisp / mml2015.el
index 4272f3f..7a4d763 100644 (file)
@@ -1,5 +1,5 @@
 ;;; mml2015.el --- MIME Security with Pretty Good Privacy (PGP)
-;; Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
 ;; Keywords: PGP MIME MML
               (buffer-string)))
            (set-buffer cipher)
            (erase-buffer)
-           (insert-buffer plain)
+           (insert-buffer-substring plain)
            (goto-char (point-min))
            (while (search-forward "\r\n" nil t)
              (replace-match "\n" t t))))
       (goto-char (point-max))
       (insert (format "\n--%s\n" boundary))
       (insert "Content-Type: application/pgp-signature\n\n")
-      (insert-buffer signature)
+      (insert-buffer-substring signature)
       (goto-char (point-max))
       (insert (format "--%s--\n" boundary))
       (goto-char (point-max)))))
        (insert "Version: 1\n\n")
        (insert (format "--%s\n" boundary))
        (insert "Content-Type: application/octet-stream\n\n")
-       (insert-buffer cipher)
+       (insert-buffer-substring cipher)
        (goto-char (point-max))
        (insert (format "--%s--\n" boundary))
        (goto-char (point-max))))))
                mm-security-handle 'gnus-details "Quit.")
               nil))
            (with-current-buffer pgg-output-buffer
+             (goto-char (point-min))
+             (while (search-forward "\r\n" nil t)
+               (replace-match "\n" t t))
              (setq handles (mm-dissect-buffer t))
              (mm-destroy-parts handle)
              (mm-set-handle-multipart-parameter
             (buffer-string))))
        (progn
          (erase-buffer)
-         (insert-buffer pgg-output-buffer)
+         (insert-buffer-substring pgg-output-buffer)
+         (goto-char (point-min))
+         (while (search-forward "\r\n" nil t)
+           (replace-match "\n" t t))
          (mm-set-handle-multipart-parameter
           mm-security-handle 'gnus-info "OK"))
       (mm-set-handle-multipart-parameter
                (prog1
                    (pgg-verify-region (point-min) (point-max)
                                       signature-file t)
+                 (goto-char (point-min))
+                 (while (search-forward "\r\n" nil t)
+                   (replace-match "\n" t t))
                  (mm-set-handle-multipart-parameter
                   mm-security-handle 'gnus-details
                   (concat (with-current-buffer pgg-output-buffer
 
 (defun mml2015-pgg-clear-verify ()
   (let ((pgg-errors-buffer mml2015-result-buffer)
-       (text (current-buffer)))
+       (text (buffer-string))
+       (coding-system buffer-file-coding-system))
     (if (condition-case err
            (prog1
                (mm-with-unibyte-buffer
-                 (insert-buffer text)
+                 (insert (encode-coding-string text coding-system))
                  (pgg-verify-region (point-min) (point-max) nil t))
+             (goto-char (point-min))
+             (while (search-forward "\r\n" nil t)
+               (replace-match "\n" t t))
              (mm-set-handle-multipart-parameter
               mm-security-handle 'gnus-details
               (concat (with-current-buffer pgg-output-buffer
 
 (defun mml2015-pgg-sign (cont)
   (let ((pgg-errors-buffer mml2015-result-buffer)
-       (boundary (funcall mml-boundary-function (incf mml-multipart-number))))
+       (boundary (funcall mml-boundary-function (incf mml-multipart-number)))
+       (pgg-default-user-id (or (message-options-get 'message-sender)
+                                pgg-default-user-id)))
     (unless (pgg-sign-region (point-min) (point-max))
       (pop-to-buffer mml2015-result-buffer)
       (error "Sign error"))
     (goto-char (point-max))
     (insert (format "\n--%s\n" boundary))
     (insert "Content-Type: application/pgp-signature\n\n")
-    (insert-buffer pgg-output-buffer)
+    (insert-buffer-substring pgg-output-buffer)
     (goto-char (point-max))
     (insert (format "--%s--\n" boundary))
     (goto-char (point-max))))
     (insert "Version: 1\n\n")
     (insert (format "--%s\n" boundary))
     (insert "Content-Type: application/octet-stream\n\n")
-    (insert-buffer pgg-output-buffer)
+    (insert-buffer-substring pgg-output-buffer)
     (goto-char (point-max))
     (insert (format "--%s--\n" boundary))
     (goto-char (point-max))))