Gnus development mailing list
 help / color / mirror / Atom feed
* Make rfc2231-decode-encoded-string more robust
@ 2008-05-05 20:22 Joao Cachopo
  2008-05-30 10:06 ` Katsumi Yamaoka
  0 siblings, 1 reply; 5+ messages in thread
From: Joao Cachopo @ 2008-05-05 20:22 UTC (permalink / raw)
  To: ding

[-- 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-05-30 10:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-05 20:22 Make rfc2231-decode-encoded-string more robust Joao Cachopo
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

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).