Gnus development mailing list
 help / color / mirror / Atom feed
From: Joao Cachopo <joao@cachopo.org>
To: ding@gnus.org
Subject: Make rfc2231-decode-encoded-string more robust
Date: Mon, 05 May 2008 21:22:07 +0100	[thread overview]
Message-ID: <m2prs0ec28.fsf@cachopo.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 559 bytes --]


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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: rfc2231.patch --]
[-- Type: text/x-patch, Size: 888 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 38 bytes --]


What do you think?

-- 
João Cachopo

             reply	other threads:[~2008-05-05 20:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-05 20:22 Joao Cachopo [this message]
2008-05-30 10:06 ` Katsumi Yamaoka
2008-05-30 10:25   ` Joao Cachopo
2008-05-30 10:32     ` Katsumi Yamaoka
2008-05-30 10:40       ` Joao Cachopo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2prs0ec28.fsf@cachopo.org \
    --to=joao@cachopo.org \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).