* mml1991.el (mml1991-pgg-sign): Make sure to load pgg.el before binding pgg-*
authorKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 26 Apr 2006 10:59:14 +0000 (10:59 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 26 Apr 2006 10:59:14 +0000 (10:59 +0000)
 variables;
 reimplement the section which prevents MIME header from being signed.
(mml1991-pgg-encrypt): Make sure to load pgg.el before binding pgg-text-mode;
 remove a blank line at the top of body.

* mm-uu.el (mm-uu-pgp-encrypted-extract-1): Don't remove blank lines at the top
 of body;
 use gnus-newsgroup-charset if there's no Charset header.

lisp/mm-uu.el
lisp/mml1991.el

index ad47246..c9a41c0 100644 (file)
@@ -544,12 +544,9 @@ apply the face `mm-uu-extract'."
                                                           'gnus-info)
                        "OK")))
          (progn
-           ;; Remove leading blank lines.
-           (goto-char (point-min))
-           (when (looking-at "\n+")
-             (delete-region (point-min) (match-end 0)))
            ;; Decode charset.
-           (when (and charset
+           (when (and (or charset
+                          (setq charset gnus-newsgroup-charset))
                       (setq charset (mm-charset-to-coding-system charset))
                       (not (eq charset 'ascii)))
              (mm-decode-coding-region (point-min) (point-max) charset))
index 0c6bb67..23953cd 100644 (file)
   (defvar pgg-output-buffer))
 
 (defun mml1991-pgg-sign (cont)
+  ;; Make sure to load pgg.el before binding pgg-* variables.
+  (require 'pgg)
   (let ((pgg-text-mode t)
+       (pgg-default-user-id (or (message-options-get 'mml-sender)
+                                pgg-default-user-id))
        headers cte)
     ;; Don't sign headers.
     (goto-char (point-min))
-    (while (not (looking-at "^$"))
-      (forward-line))
-    (unless (eobp) ;; no headers?
+    (when (re-search-forward "^$" nil t)
       (setq headers (buffer-substring (point-min) (point)))
-      (forward-line) ;; skip header/body separator
-      (delete-region (point-min) (point)))
-    (when (string-match "^Content-Transfer-Encoding: \\(.+\\)" headers)
-      (setq cte (intern (match-string 1 headers))))
-    (mm-decode-content-transfer-encoding cte)
-    (unless (let ((pgg-default-user-id
-                  (or (message-options-get 'mml-sender)
-                      pgg-default-user-id)))
-             (pgg-sign-region (point-min) (point-max) t))
+      (save-restriction
+       (narrow-to-region (point-min) (point))
+       (setq cte (mail-fetch-field "content-transfer-encoding")))
+      (forward-line 1)
+      (delete-region (point-min) (point))
+      (when cte
+       (setq cte (intern (downcase cte)))
+       (mm-decode-content-transfer-encoding cte)))
+    (unless (pgg-sign-region (point-min) (point-max) t)
       (pop-to-buffer pgg-errors-buffer)
       (error "Encrypt error"))
     (delete-region (point-min) (point-max))
       (goto-char (point-min))
       (while (re-search-forward "\r+$" nil t)
        (replace-match "" t t))
-      (mm-encode-content-transfer-encoding cte)
+      (when cte
+       (mm-encode-content-transfer-encoding cte))
       (goto-char (point-min))
       (when headers
        (insert headers))
     t))
 
 (defun mml1991-pgg-encrypt (cont &optional sign)
-  (let ((pgg-text-mode t)
-       cte)
-    ;; Strip MIME Content[^ ]: headers since it will be ASCII ARMOURED
-    (goto-char (point-min))
-    (while (looking-at "^Content[^ ]+:")
-      (when (looking-at "^Content-Transfer-Encoding: \\(.+\\)")
-       (setq cte (intern (match-string 1))))
-      (forward-line))
-    (unless (bobp)
-      (delete-region (point-min) (point)))
-    (mm-decode-content-transfer-encoding cte)
-    (unless (pgg-encrypt-region
-            (point-min) (point-max)
-            (split-string
-             (or
-              (message-options-get 'message-recipients)
-              (message-options-set 'message-recipients
-                                   (read-string "Recipients: ")))
-             "[ \f\t\n\r\v,]+")
-            sign)
-      (pop-to-buffer pgg-errors-buffer)
-      (error "Encrypt error"))
-    (delete-region (point-min) (point-max))
-    ;;(insert "Content-Type: application/pgp-encrypted\n\n")
-    ;;(insert "Version: 1\n\n")
-    (insert "\n")
-    (insert-buffer-substring pgg-output-buffer)
-    t))
+  (goto-char (point-min))
+  (when (re-search-forward "^$" nil t)
+    (let ((cte (save-restriction
+                (narrow-to-region (point-min) (point))
+                (mail-fetch-field "content-transfer-encoding"))))
+      ;; Strip MIME headers since it will be ASCII armoured.
+      (forward-line 1)
+      (delete-region (point-min) (point))
+      (when cte
+       (mm-decode-content-transfer-encoding (intern (downcase cte))))))
+  (unless (progn
+           ;; Make sure to load pgg.el before binding `pgg-text-mode'.
+           (require 'pgg)
+           (let ((pgg-text-mode t))
+             (pgg-encrypt-region
+              (point-min) (point-max)
+              (split-string
+               (or
+                (message-options-get 'message-recipients)
+                (message-options-set 'message-recipients
+                                     (read-string "Recipients: ")))
+               "[ \f\t\n\r\v,]+")
+              sign)))
+    (pop-to-buffer pgg-errors-buffer)
+    (error "Encrypt error"))
+  (delete-region (point-min) (point-max))
+  (insert "\n")
+  (insert-buffer-substring pgg-output-buffer)
+  t)
 
 ;;;###autoload
 (defun mml1991-encrypt (cont &optional sign)