From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.bugs Subject: bug#11282: 24.1.50; Error in decoding message Date: Fri, 04 May 2012 15:33:55 +0900 Message-ID: <87ehr078vg.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1336113530 13748 80.91.229.3 (4 May 2012 06:38:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 4 May 2012 06:38:50 +0000 (UTC) Cc: 11282@debbugs.gnu.org To: rms@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 04 08:38:48 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SQCAB-0001Fz-PU for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 May 2012 08:38:48 +0200 Original-Received: from localhost ([::1]:36861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQCAA-0000Rw-TL for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 May 2012 02:38:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQC7q-0000OE-GF for bug-gnu-emacs@gnu.org; Fri, 04 May 2012 02:36:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SQC7o-0004nB-5e for bug-gnu-emacs@gnu.org; Fri, 04 May 2012 02:36:21 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQC7o-0004n5-18 for bug-gnu-emacs@gnu.org; Fri, 04 May 2012 02:36:20 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SQC9R-0005gS-Nf for bug-gnu-emacs@gnu.org; Fri, 04 May 2012 02:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kenichi Handa Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 May 2012 06:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11282 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11282-submit@debbugs.gnu.org id=B11282.133611342821791 (code B ref 11282); Fri, 04 May 2012 06:38:01 +0000 Original-Received: (at 11282) by debbugs.gnu.org; 4 May 2012 06:37:08 +0000 Original-Received: from localhost ([127.0.0.1]:35579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SQC8Z-0005fN-Pb for submit@debbugs.gnu.org; Fri, 04 May 2012 02:37:08 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:43454 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SQC7e-0005df-3a for 11282@debbugs.gnu.org; Fri, 04 May 2012 02:36:11 -0400 Original-Received: from 126.229.accsnet.ne.jp ([202.220.229.126]:53374 helo=ubuntu) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SQC5s-0002gn-1H; Fri, 04 May 2012 02:34:20 -0400 In-Reply-To: (message from Richard Stallman on Thu, 19 Apr 2012 14:39:13 -0400) X-Mailman-Approved-At: Fri, 04 May 2012 02:37:06 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-Mailman-Approved-At: Fri, 04 May 2012 02:38:45 -0400 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:59731 Archived-At: In article , Richard Stallman writes: > When I visit this as an Rmail file, Rmail gets an error > decoding the coding system. Maybe the message really is > invalid, but Rmail should not get an unhandled Lisp error. > Here is the backtrace. > Debugger entered--Lisp error: (wrong-type-argument wholenump nil) > decode-coding-region(888 1351 utf-7) > rmail-mime-insert-decoded-text([("text/html" (charset . "utf-7")) ("inline") "7bit" [[nil nil nil] [t nil t]] [# # t] ["" (nil) nil] [# # t] nil rmail-mime-insert-text nil]) [...] I've just installed this change to the trunk. I think it should also be applied to 24.1. 2012-05-03 Kenichi Handa * mail/rmailmm.el (rmail-show-mime): Catch an error caused by text decoding, and show a warning message without signalling an error (Bug#11282). === modified file 'lisp/mail/rmailmm.el' --- lisp/mail/rmailmm.el 2012-01-19 07:21:25 +0000 +++ lisp/mail/rmailmm.el 2012-05-03 05:47:24 +0000 @@ -1300,26 +1300,40 @@ (rmail-mime-mbox-buffer rmail-buffer) (rmail-mime-view-buffer rmail-view-buffer) (rmail-mime-coding-system nil)) + ;; If ENTITY is not a vector, it is a string describing an error. (if (vectorp entity) (with-current-buffer rmail-mime-view-buffer (erase-buffer) - (rmail-mime-insert entity) - (if (consp rmail-mime-coding-system) - ;; Decoding is done by rfc2047-decode-region only for a - ;; header. But, as the used coding system may have been - ;; overridden by mm-charset-override-alist, we can't - ;; trust (car rmail-mime-coding-system). So, here we - ;; try the decoding again with mm-charset-override-alist - ;; bound to nil. - (let ((mm-charset-override-alist nil)) - (setq rmail-mime-coding-system - (rmail-mime-find-header-encoding - (rmail-mime-entity-header entity))))) - (set-buffer-file-coding-system - (if rmail-mime-coding-system - (coding-system-base rmail-mime-coding-system) - 'undecided) - t t)) + ;; This condition-case is for catching an error in the + ;; internal MIME decoding (e.g. incorrect BASE64 form) that + ;; may be signaled by rmail-mime-insert. + ;; FIXME: The current code doesn't set a proper error symbol + ;; in ERR. We must find a way to propagate a correct error + ;; symbol that is caused in the very deep code of text + ;; decoding (e.g. an error by base64-decode-region called by + ;; post-read-conversion function of utf-7). + (condition-case err + (progn + (rmail-mime-insert entity) + (if (consp rmail-mime-coding-system) + ;; Decoding is done by rfc2047-decode-region only for a + ;; header. But, as the used coding system may have been + ;; overridden by mm-charset-override-alist, we can't + ;; trust (car rmail-mime-coding-system). So, here we + ;; try the decoding again with mm-charset-override-alist + ;; bound to nil. + (let ((mm-charset-override-alist nil)) + (setq rmail-mime-coding-system + (rmail-mime-find-header-encoding + (rmail-mime-entity-header entity))))) + (set-buffer-file-coding-system + (if rmail-mime-coding-system + (coding-system-base rmail-mime-coding-system) + 'undecided) + t t)) + (error (setq entity (format "%s" err)))))) + ;; Re-check ENTITY. It may be set to an error string. + (when (stringp entity) ;; Decoding failed. ENTITY is an error message. Insert the ;; original message body as is, and show warning. (let ((region (with-current-buffer rmail-mime-mbox-buffer