diff options
| author | Kenichi Handa | 2010-12-24 23:00:14 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2010-12-24 23:00:14 +0900 |
| commit | 8258ae3f5ab8c96821eaa283530c5c01c38e565d (patch) | |
| tree | efc8d9c71f764c188ed802efb9939c723705cecc | |
| parent | 76428f01c6b5a4ad6a3c33c0cbfa94c3431578b9 (diff) | |
| download | emacs-8258ae3f5ab8c96821eaa283530c5c01c38e565d.tar.gz emacs-8258ae3f5ab8c96821eaa283530c5c01c38e565d.zip | |
Fix error handling of MIME parsing.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/mail/rmailmm.el | 20 |
2 files changed, 19 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ee6848449c7..f25b74d6224 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2010-12-24 Kenichi Handa <handa@m17n.org> | 1 | 2010-12-24 Kenichi Handa <handa@m17n.org> |
| 2 | 2 | ||
| 3 | * mail/rmailmm.el (rmail-mime-parse): Perform parsing in | ||
| 4 | condition-case and return an error message string if something | ||
| 5 | goes wrong. | ||
| 6 | (rmail-show-mime): Adjusted for the above change. Insert the | ||
| 7 | header by rmail-mime-insert-header. | ||
| 8 | |||
| 9 | 2010-12-24 Kenichi Handa <handa@m17n.org> | ||
| 10 | |||
| 3 | * mail/rmailmm.el: New key bindings for rmail-mime-next-item, | 11 | * mail/rmailmm.el: New key bindings for rmail-mime-next-item, |
| 4 | rmail-mime-previous-item, and rmail-mime-toggle-hidden. | 12 | rmail-mime-previous-item, and rmail-mime-toggle-hidden. |
| 5 | (rmail-mime-mbox-buffer) | 13 | (rmail-mime-mbox-buffer) |
diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el index 5733945d5f2..307ec0632bc 100644 --- a/lisp/mail/rmailmm.el +++ b/lisp/mail/rmailmm.el | |||
| @@ -1130,11 +1130,12 @@ modified." | |||
| 1130 | 1130 | ||
| 1131 | (defun rmail-mime-parse () | 1131 | (defun rmail-mime-parse () |
| 1132 | "Parse the current Rmail message as a MIME message. | 1132 | "Parse the current Rmail message as a MIME message. |
| 1133 | The value is a MIME-entiy object (see `rmail-mime-entity')." | 1133 | The value is a MIME-entiy object (see `rmail-mime-entity'). |
| 1134 | If an error occurs, return an error message string." | ||
| 1134 | (let ((rmail-mime-mbox-buffer (if (rmail-buffers-swapped-p) | 1135 | (let ((rmail-mime-mbox-buffer (if (rmail-buffers-swapped-p) |
| 1135 | rmail-view-buffer | 1136 | rmail-view-buffer |
| 1136 | (current-buffer)))) | 1137 | (current-buffer)))) |
| 1137 | ;;(condition-case err | 1138 | (condition-case err |
| 1138 | (with-current-buffer rmail-mime-mbox-buffer | 1139 | (with-current-buffer rmail-mime-mbox-buffer |
| 1139 | (save-excursion | 1140 | (save-excursion |
| 1140 | (goto-char (point-min)) | 1141 | (goto-char (point-min)) |
| @@ -1148,8 +1149,7 @@ The value is a MIME-entiy object (see `rmail-mime-entity')." | |||
| 1148 | (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 nil)) | 1149 | (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 nil)) |
| 1149 | (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 t))) | 1150 | (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 t))) |
| 1150 | entity))) | 1151 | entity))) |
| 1151 | ;;(error (error (format "%s" err)))) | 1152 | (error (format "%s" err))))) |
| 1152 | )) | ||
| 1153 | 1153 | ||
| 1154 | (defun rmail-mime-insert (entity) | 1154 | (defun rmail-mime-insert (entity) |
| 1155 | "Insert a MIME-entity ENTITY in the current buffer. | 1155 | "Insert a MIME-entity ENTITY in the current buffer. |
| @@ -1251,25 +1251,27 @@ attachments as specfied by `rmail-mime-attachment-dirs-alist'." | |||
| 1251 | (rmail-mime-mbox-buffer rmail-buffer) | 1251 | (rmail-mime-mbox-buffer rmail-buffer) |
| 1252 | (rmail-mime-view-buffer rmail-view-buffer) | 1252 | (rmail-mime-view-buffer rmail-view-buffer) |
| 1253 | (rmail-mime-coding-system nil)) | 1253 | (rmail-mime-coding-system nil)) |
| 1254 | (if entity | 1254 | (if (vectorp entity) |
| 1255 | (with-current-buffer rmail-mime-view-buffer | 1255 | (with-current-buffer rmail-mime-view-buffer |
| 1256 | (erase-buffer) | 1256 | (erase-buffer) |
| 1257 | (rmail-mime-insert entity) | 1257 | (rmail-mime-insert entity) |
| 1258 | (if rmail-mime-coding-system | 1258 | (if rmail-mime-coding-system |
| 1259 | (set-buffer-file-coding-system rmail-mime-coding-system t t))) | 1259 | (set-buffer-file-coding-system rmail-mime-coding-system t t))) |
| 1260 | ;; Decoding failed. Insert the original message body as is. | 1260 | ;; Decoding failed. ENTITY is an error message. Insert the |
| 1261 | ;; original message body as is, and show warning. | ||
| 1261 | (let ((region (with-current-buffer rmail-mime-mbox-buffer | 1262 | (let ((region (with-current-buffer rmail-mime-mbox-buffer |
| 1262 | (goto-char (point-min)) | 1263 | (goto-char (point-min)) |
| 1263 | (re-search-forward "^$" nil t) | 1264 | (re-search-forward "^$" nil t) |
| 1264 | (forward-line 1) | 1265 | (forward-line 1) |
| 1265 | (cons (point) (point-max))))) | 1266 | (vector (point-min) (point) (point-max))))) |
| 1266 | (with-current-buffer rmail-mime-view-buffer | 1267 | (with-current-buffer rmail-mime-view-buffer |
| 1267 | (let ((inhibit-read-only t)) | 1268 | (let ((inhibit-read-only t)) |
| 1268 | (erase-buffer) | 1269 | (erase-buffer) |
| 1270 | (rmail-mime-insert-header region) | ||
| 1269 | (insert-buffer-substring rmail-mime-mbox-buffer | 1271 | (insert-buffer-substring rmail-mime-mbox-buffer |
| 1270 | (car region) (cdr region)))) | 1272 | (aref region 1) (aref region 2)))) |
| 1271 | (set-buffer-file-coding-system 'no-conversion t t) | 1273 | (set-buffer-file-coding-system 'no-conversion t t) |
| 1272 | (message "MIME decoding failed"))))) | 1274 | (message "MIME decoding failed: %s" entity))))) |
| 1273 | 1275 | ||
| 1274 | (setq rmail-show-mime-function 'rmail-show-mime) | 1276 | (setq rmail-show-mime-function 'rmail-show-mime) |
| 1275 | 1277 | ||