(narrow-to-region start end)
(goto-char start)
(let ((method (cdr (assoc 'method situation)))
- (name (mime-raw-get-filename situation)))
+ (name (mime-entity-safe-filename entity)))
(setq name
(if name
(expand-file-name name mime-temp-directory)
(remove-alist 'mime-mailcap-method-filename-alist process)
(message (format "%s %s" process event)))
-;; (defun mime-activate-external-method (entity cal)
-;; (save-excursion
-;; (save-restriction
-;; (let ((beg (mime-entity-point-min entity))
-;; (end (mime-entity-point-max entity)))
-;; (narrow-to-region beg end)
-;; (goto-char beg)
-;; (let ((method (cdr (assoc 'method cal)))
-;; (name (mime-raw-get-filename cal)))
-;; (if method
-;; (let ((file (make-temp-name
-;; (expand-file-name "TM" mime-temp-directory)))
-;; b args)
-;; (if (nth 1 method)
-;; (setq b beg)
-;; (setq b (mime-entity-body-start entity)))
-;; (goto-char b)
-;; (write-region b end file)
-;; (message "External method is starting...")
-;; (setq cal (put-alist
-;; 'name (replace-as-filename name) cal))
-;; (setq cal (put-alist 'file file cal))
-;; (setq args (nconc
-;; (list (car method)
-;; mime-echo-buffer-name (car method))
-;; (mime-make-external-method-args
-;; cal (cdr (cdr method)))
-;; ))
-;; (apply (function start-process) args)
-;; (mime-show-echo-buffer)
-;; ))
-;; )))))
-
-;; (defun mime-make-external-method-args (cal format)
-;; (mapcar (function
-;; (lambda (arg)
-;; (if (stringp arg)
-;; arg
-;; (let* ((item (eval arg))
-;; (ret (cdr (assoc item cal))))
-;; (or ret
-;; (if (eq item 'encoding)
-;; "7bit"
-;; ""))
-;; ))))
-;; format))
-
(defvar mime-echo-window-is-shared-with-bbdb t
"*If non-nil, mime-echo window is shared with BBDB window.")
(concat (regexp-* mime-view-file-name-char-regexp)
"\\(\\." mime-view-file-name-char-regexp "+\\)*"))
-(defun mime-raw-get-original-filename (param)
- (or (if (member (cdr (assq 'encoding param))
- mime-view-uuencode-encoding-name-list)
- (mime-raw-get-uu-filename))
- (let (ret)
- (or (if (or (and (setq ret (mime-read-Content-Disposition))
- (setq ret
- (assoc
- "filename"
- (mime-content-disposition-parameters ret)))
- )
- (setq ret (assoc "name" param))
- (setq ret (assoc "x-name" param))
- )
- (std11-strip-quoted-string (cdr ret))
- )
- (if (setq ret
- (std11-find-field-body '("Content-Description"
- "Subject")))
- (if (or (string-match mime-view-file-name-regexp-1 ret)
- (string-match mime-view-file-name-regexp-2 ret))
- (substring ret (match-beginning 0)(match-end 0))
- ))
- ))
+(defun mime-entity-filename (entity)
+ (or (mime-entity-uu-filename entity)
+ (let ((ret (mime-entity-content-disposition entity)))
+ (and ret
+ (setq ret (mime-content-disposition-filename ret))
+ (std11-strip-quoted-string ret)
+ ))
+ (let ((ret (mime-entity-content-type entity)))
+ (and ret
+ (setq ret
+ (cdr
+ (let ((param (mime-content-type-parameters ret)))
+ (or (assoc "name" param)
+ (assoc "x-name" param))
+ )))
+ (std11-strip-quoted-string ret)
+ ))
))
-(defun mime-raw-get-filename (param)
- (replace-as-filename (mime-raw-get-original-filename param))
- )
+(defun mime-entity-safe-filename (entity)
+ (replace-as-filename
+ (or (mime-entity-filename entity)
+ (let ((ret (or (mime-entity-read-field entity 'Content-Description)
+ (mime-entity-read-field entity 'Subject))))
+ (if (or (string-match mime-view-file-name-regexp-1 ret)
+ (string-match mime-view-file-name-regexp-2 ret))
+ (substring ret (match-beginning 0)(match-end 0))
+ )))))
;;; @ file extraction
(goto-char beg)
(let* ((name (save-restriction
(narrow-to-region beg end)
- (mime-raw-get-filename cal)
+ (mime-entity-safe-filename entity)
))
(encoding (or (cdr (assq 'encoding cal)) "7bit"))
(filename (if (and name (not (string-equal name "")))
(goto-char beg)
(let* ((name (save-restriction
(narrow-to-region beg end)
- (mime-raw-get-filename situation)
+ (mime-entity-safe-filename entity)
))
(encoding (or (cdr (assq 'encoding situation)) "7bit"))
(filename (if (and name (not (string-equal name "")))