- (let ((text-start (point)) start-char end-char
- type file-name end-line result)
- (while (re-search-forward mm-uu-begin-line nil t)
- (beginning-of-line)
- (setq start-char (point))
- (forward-line) ;; in case of failure
- (setq type (cdr (assq (aref (match-string 0) 0)
- mm-uu-identifier-alist)))
- (setq file-name
- (if (eq type 'uu)
- (and (match-string 1)
- (let ((nnheader-file-name-translation-alist
- '((?/ . ?,) (? . ?_) (?* . ?_) (?$ . ?_))))
- (nnheader-translate-file-chars (match-string 1))))))
- (setq end-line (symbol-value
- (intern (concat "mm-uu-" (symbol-name type)
- "-end-line"))))
- (when (re-search-forward end-line nil t)
- (forward-line)
- (setq end-char (point))
- (when (or (not (eq type 'binhex))
- (setq file-name
- (condition-case nil
- (binhex-decode-region start-char end-char t)
- (error nil))))
- (if (> start-char text-start)
- (push
- (list (mm-uu-copy-to-buffer text-start start-char)
- '("text/plain") nil nil nil nil)
- result))
- (push
- (cond
- ((eq type 'postscript)
- (list (mm-uu-copy-to-buffer start-char end-char)
- '("application/postscript") nil nil nil nil))
- ((eq type 'uu)
- (list (mm-uu-copy-to-buffer start-char end-char)
- (list (or (and file-name
- (string-match "\\.[^\\.]+$" file-name)
- (mailcap-extension-to-mime
- (match-string 0 file-name)))
- "application/octet-stream"))
- mm-uu-decode-function nil
- (if (and file-name (not (equal file-name "")))
- (list "attachment" (cons 'filename file-name)))
- file-name))
- ((eq type 'binhex)
- (list (mm-uu-copy-to-buffer start-char end-char)
- (list (or (and file-name
- (string-match "\\.[^\\.]+$" file-name)
- (mailcap-extension-to-mime
- (match-string 0 file-name)))
- "application/octet-stream"))
- mm-uu-binhex-decode-function nil
- (if (and file-name (not (equal file-name "")))
- (list "attachment" (cons 'filename file-name)))
- file-name))
- ((eq type 'shar)
- (list (mm-uu-copy-to-buffer start-char end-char)
- '("application/x-shar") nil nil nil nil)))
- result)
- (setq text-start end-char))))
+ (narrow-to-region (point) end-point)
+ (mm-dissect-buffer t)))
+
+(defun mm-uu-pgp-signed-test (&rest rest)
+ (and
+ mml2015-use
+ (mml2015-clear-verify-function)
+ (cond
+ ((eq mm-verify-option 'never) nil)
+ ((eq mm-verify-option 'always) t)
+ ((eq mm-verify-option 'known) t)
+ (t (y-or-n-p "Verify pgp signed part? ")))))
+
+(eval-when-compile
+ (defvar gnus-newsgroup-charset))
+
+(defun mm-uu-pgp-signed-extract-1 (handles ctl)
+ (let ((buf (mm-uu-copy-to-buffer (point-min) (point-max))))
+ (with-current-buffer buf
+ (if (mm-uu-pgp-signed-test)
+ (progn
+ (mml2015-clean-buffer)
+ (let ((coding-system-for-write (or gnus-newsgroup-charset
+ 'iso-8859-1)))
+ (funcall (mml2015-clear-verify-function))))
+ (when (and mml2015-use (null (mml2015-clear-verify-function)))
+ (mm-set-handle-multipart-parameter
+ mm-security-handle 'gnus-details
+ (format "Clear verification not supported by `%s'.\n" mml2015-use))))
+ (goto-char (point-min))
+ (if (search-forward "\n\n" nil t)
+ (delete-region (point-min) (point)))
+ (if (re-search-forward mm-uu-pgp-beginning-signature nil t)
+ (delete-region (match-beginning 0) (point-max)))
+ (goto-char (point-min))
+ (while (re-search-forward "^- " nil t)
+ (replace-match "" t t)
+ (forward-line 1)))
+ (list (mm-make-handle buf mm-uu-text-plain-type))))
+
+(defun mm-uu-pgp-signed-extract ()
+ (let ((mm-security-handle (list (format "multipart/signed"))))
+ (mm-set-handle-multipart-parameter
+ mm-security-handle 'protocol "application/x-gnus-pgp-signature")
+ (save-restriction
+ (narrow-to-region start-point end-point)
+ (add-text-properties 0 (length (car mm-security-handle))
+ (list 'buffer (mm-uu-copy-to-buffer))
+ (car mm-security-handle))
+ (setcdr mm-security-handle
+ (mm-uu-pgp-signed-extract-1 nil
+ mm-security-handle)))
+ mm-security-handle))
+
+(defun mm-uu-pgp-encrypted-test (&rest rest)
+ (and
+ mml2015-use
+ (mml2015-clear-decrypt-function)
+ (cond
+ ((eq mm-decrypt-option 'never) nil)
+ ((eq mm-decrypt-option 'always) t)
+ ((eq mm-decrypt-option 'known) t)
+ (t (y-or-n-p "Decrypt pgp encrypted part? ")))))
+
+(defun mm-uu-pgp-encrypted-extract-1 (handles ctl)
+ (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))))
+
+(defun mm-uu-pgp-encrypted-extract ()
+ (let ((mm-security-handle (list (format "multipart/encrypted"))))
+ (mm-set-handle-multipart-parameter
+ mm-security-handle 'protocol "application/x-gnus-pgp-encrypted")
+ (save-restriction
+ (narrow-to-region start-point end-point)
+ (add-text-properties 0 (length (car mm-security-handle))
+ (list 'buffer (mm-uu-copy-to-buffer))
+ (car mm-security-handle))
+ (setcdr mm-security-handle
+ (mm-uu-pgp-encrypted-extract-1 nil
+ mm-security-handle)))
+ mm-security-handle))
+
+(defun mm-uu-gpg-key-skip-to-last ()
+ (let ((point (point))
+ (end-regexp (mm-uu-end-regexp entry))
+ (beginning-regexp (mm-uu-beginning-regexp entry)))
+ (when (and end-regexp
+ (not (mm-uu-configure-p (mm-uu-type entry) 'disabled)))
+ (while (re-search-forward end-regexp nil t)
+ (skip-chars-forward " \t\n\r")
+ (if (looking-at beginning-regexp)
+ (setq point (match-end 0)))))
+ (goto-char point)))
+
+(defun mm-uu-pgp-key-extract ()
+ (let ((buf (mm-uu-copy-to-buffer start-point end-point)))
+ (mm-make-handle buf
+ '("application/pgp-keys"))))
+
+;;;###autoload
+(defun mm-uu-dissect (&optional noheader mime-type)
+ "Dissect the current buffer and return a list of uu handles.
+The optional NOHEADER means there's no header in the buffer.
+MIME-TYPE specifies a MIME type and parameters, which defaults to the
+value of `mm-uu-text-plain-type'."
+ (let ((case-fold-search t)
+ (mm-uu-text-plain-type (or mime-type mm-uu-text-plain-type))
+ text-start start-point end-point file-name result entry func)
+ (save-excursion
+ (goto-char (point-min))
+ (cond
+ (noheader)
+ ((looking-at "\n")
+ (forward-line))
+ ((search-forward "\n\n" nil t)
+ t)
+ (t (goto-char (point-max))))
+ (setq text-start (point))
+ (while (re-search-forward mm-uu-beginning-regexp nil t)
+ (setq start-point (match-beginning 0))
+ (let ((alist mm-uu-type-alist)
+ (beginning-regexp (match-string 0)))
+ (while (not entry)
+ (if (string-match (mm-uu-beginning-regexp (car alist))
+ beginning-regexp)
+ (setq entry (car alist))
+ (pop alist))))
+ (if (setq func (mm-uu-function-1 entry))
+ (funcall func))
+ (forward-line);; in case of failure
+ (when (and (not (mm-uu-configure-p (mm-uu-type entry) 'disabled))
+ (let ((end-regexp (mm-uu-end-regexp entry)))
+ (if (not end-regexp)
+ (or (setq end-point (point-max)) t)
+ (prog1
+ (re-search-forward end-regexp nil t)
+ (forward-line)
+ (setq end-point (point)))))
+ (or (not (setq func (mm-uu-function-2 entry)))
+ (funcall func)))
+ (if (and (> start-point text-start)
+ (progn
+ (goto-char text-start)
+ (re-search-forward "." start-point t)))
+ (push
+ (mm-make-handle (mm-uu-copy-to-buffer text-start start-point)
+ mm-uu-text-plain-type)
+ result))
+ (push
+ (funcall (mm-uu-function-extract entry))
+ result)
+ (goto-char (setq text-start end-point))))