From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/66912 Path: news.gmane.org!not-for-mail From: Joao Cachopo Newsgroups: gmane.emacs.gnus.general Subject: Make rfc2231-decode-encoded-string more robust Date: Mon, 05 May 2008 21:22:07 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1210018991 5089 80.91.229.12 (5 May 2008 20:23:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 May 2008 20:23:11 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M15392@lists.math.uh.edu Mon May 05 22:23:47 2008 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jt7De-0003JZ-2m for ding-account@gmane.org; Mon, 05 May 2008 22:23:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1Jt7Ce-0004Gq-Gi; Mon, 05 May 2008 15:22:28 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Jt7Cc-0004Ga-LP for ding@lists.math.uh.edu; Mon, 05 May 2008 15:22:26 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.67) (envelope-from ) id 1Jt7CW-0003ZN-TU for ding@lists.math.uh.edu; Mon, 05 May 2008 15:22:26 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Jt7Cj-000289-00 for ; Mon, 05 May 2008 22:22:33 +0200 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Jt7CR-0001ST-5u for ding@gnus.org; Mon, 05 May 2008 20:22:15 +0000 Original-Received: from 89.181.56.66 ([89.181.56.66]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 05 May 2008 20:22:15 +0000 Original-Received: from joao by 89.181.56.66 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 05 May 2008 20:22:15 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 89.181.56.66 User-Agent: Gnus/5.110009 (No Gnus v0.9) Emacs/22.1.91 (darwin) Cancel-Lock: sha1:fm/fkwpMlsvRstvItdQ38JG8L/A= X-Spam-Score: -1.1 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:66912 Archived-At: --=-=-= Hi! Once in a while I receive an email that Gnus fails to show, giving an error in rfc2231-decode-encoded-string. As far as I could see, the problem is with the email message, that has an incorrectly formed RFC2231 string somewhere within it. More specifically, the string ends with '%'. Probably, this is due to some broken MUA out there. Still, I think that Gnus should handle this case more gracefully, rather than not showing the email at all. Therefore, I propose the following change to the rfc2231-decode-encoded-string to make it more robust. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=rfc2231.patch Index: lisp/rfc2231.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/rfc2231.el,v retrieving revision 7.25 diff -u -r7.25 rfc2231.el --- lisp/rfc2231.el 24 Apr 2008 04:19:20 -0000 7.25 +++ lisp/rfc2231.el 5 May 2008 20:13:34 -0000 @@ -217,10 +217,11 @@ (insert value) (goto-char (point-min)) (while (search-forward "%" nil t) - (insert - (prog1 - (string-to-number (buffer-substring (point) (+ (point) 2)) 16) - (delete-region (1- (point)) (+ (point) 2))))) + (if (<= (+ (point) 2) (point-max)) + (insert + (prog1 + (string-to-number (buffer-substring (point) (+ (point) 2)) 16) + (delete-region (1- (point)) (+ (point) 2)))))) ;; Decode using the charset, if any. (if (memq coding-system '(nil ascii)) (buffer-string) --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit What do you think? -- Joćo Cachopo --=-=-=--