- (cond ((string-equal type "multipart")
- (let ((boundary (assoc-value "boundary" params)))
- (re-search-forward (concat "\n--" boundary) nil t)
- (let ((bb (match-beginning 0)) eb tag)
- (setq tag (format "\n--<<%s>>-{" stype))
- (goto-char bb)
- (insert tag)
- (setq bb (+ bb (length tag)))
- (re-search-forward (concat "\n--" boundary "--") nil t)
- (setq eb (match-beginning 0))
- (replace-match (format "\n--}-<<%s>>" stype))
- (save-restriction
- (narrow-to-region bb eb)
- (goto-char (point-min))
- (while (re-search-forward
- (concat "\n--" boundary "\n") nil t)
- (let ((beg (match-beginning 0))
- end)
- (delete-region beg (match-end 0))
- (save-excursion
- (if (re-search-forward
- (concat "\n--" boundary) nil t)
- (setq end (match-beginning 0))
- (setq end (point-max))
- )
- (save-restriction
- (narrow-to-region beg end)
- (mime-editor::edit-again code-conversion)
- (goto-char (point-max))
- ))))
- ))
- (goto-char (point-min))
- (or (= (point-min) 1)
- (delete-region (point-min)
- (if (re-search-forward "^$" nil t)
- (match-end 0)
- (point-min)
- )))
- ))
- (t
- (let* ((str (rfc822/get-header-string-except
- "^Content-Type" ""))
- charset
- (pstr
- (mapconcat (function
- (lambda (attr)
- (if (string-equal (car attr)
- "charset")
- (progn
- (setq charset (cdr attr))
- "")
- (concat ";" (car attr)
- "=" (cdr attr))
- )
- ))
- params ""))
- )
- (if code-conversion
- (if charset
- (mime/code-convert-region-to-emacs
- (point-min) (point-max) charset)
- (decode-coding-region
- (point-min) (point-max)
- mime/default-coding-system)
- ))
- (and str
- (setq pstr (concat pstr "\n" str))
- )
- (let ((he
- (if (re-search-forward "^$" nil t)
- (match-end 0)
- (point-min)
- )))
- (if (= (point-min) 1)
- (progn
- (goto-char he)
- (insert
- (concat
- "\n"
- (mime-create-tag (concat type "/" stype))
- ))
- )
- (delete-region (point-min) he)
- (insert
- (concat "\n" (mime-create-tag
- (concat type "/" stype pstr))))
- ))
- ))))
+ (cond
+ ((string= ctype "application/pgp-signature")
+ (delete-region (point-min)(point-max))
+ )
+ ((string= type "multipart")
+ (let* ((boundary (assoc-value "boundary" params))
+ (boundary-pat
+ (concat "\n--" (regexp-quote boundary) "[ \t]*\n"))
+ )
+ (re-search-forward boundary-pat nil t)
+ (let ((bb (match-beginning 0)) eb tag)
+ (setq tag (format "\n--<<%s>>-{\n" stype))
+ (goto-char bb)
+ (insert tag)
+ (setq bb (+ bb (length tag)))
+ (re-search-forward
+ (concat "\n--" (regexp-quote boundary) "--[ \t]*\n")
+ nil t)
+ (setq eb (match-beginning 0))
+ (replace-match (format "--}-<<%s>>\n" stype))
+ (save-restriction
+ (narrow-to-region bb eb)
+ (goto-char (point-min))
+ (while (re-search-forward boundary-pat nil t)
+ (let ((beg (match-beginning 0))
+ end)
+ (delete-region beg (match-end 0))
+ (save-excursion
+ (if (re-search-forward boundary-pat nil t)
+ (setq end (match-beginning 0))
+ (setq end (point-max))
+ )
+ (save-restriction
+ (narrow-to-region beg end)
+ (mime-editor::edit-again code-conversion)
+ (goto-char (point-max))
+ ))))
+ ))
+ (goto-char (point-min))
+ (or (= (point-min) 1)
+ (delete-region (point-min)
+ (if (search-forward "\n\n" nil t)
+ (match-end 0)
+ (point-min)
+ )))
+ ))
+ (t
+ (let* (charset
+ (pstr
+ (let ((bytes (+ 14 (length ctype))))
+ (mapconcat (function
+ (lambda (attr)
+ (if (string-equal (car attr) "charset")
+ (progn
+ (setq charset (cdr attr))
+ "")
+ (let* ((str
+ (concat (car attr)
+ "=" (cdr attr))
+ )
+ (bs (length str))
+ )
+ (setq bytes (+ bytes bs 2))
+ (if (< bytes 76)
+ (concat "; " str)
+ (setq bytes (+ bs 1))
+ (concat ";\n " str)
+ )
+ ))))
+ params "")))
+ encoding
+ encoded)
+ (save-excursion
+ (if (re-search-forward
+ "Content-Transfer-Encoding:" nil t)
+ (let ((beg (match-beginning 0))
+ (hbeg (match-end 0))
+ (end (std11-field-end)))
+ (setq encoding
+ (eliminate-top-spaces
+ (std11-unfold-string
+ (buffer-substring hbeg end))))
+ (if (or charset (string-equal type "text"))
+ (progn
+ (delete-region beg (1+ end))
+ (goto-char (point-min))
+ (if (search-forward "\n\n" nil t)
+ (progn
+ (mime-decode-region
+ (match-end 0)(point-max) encoding)
+ (setq encoded t
+ encoding nil)
+ )))))))
+ (if (or code-conversion encoded)
+ (decode-mime-charset-region
+ (point-min)(point-max)
+ (or charset default-mime-charset))
+ )
+ (let ((he
+ (if (re-search-forward "^$" nil t)
+ (match-end 0)
+ (point-min)
+ )))
+ (if (= (point-min) 1)
+ (progn
+ (goto-char he)
+ (insert
+ (concat "\n"
+ (mime-create-tag
+ (concat type "/" stype pstr) encoding)))
+ )
+ (delete-region (point-min) he)
+ (insert
+ (mime-create-tag
+ (concat type "/" stype pstr) encoding))
+ ))
+ ))))