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

* Re: Make rfc2231-decode-encoded-string more robust
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Katsumi Yamaoka @ 2008-05-30 10:06 UTC (permalink / raw)
  To: Joao Cachopo; +Cc: ding

>>>>> Joao Cachopo wrote:

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

I think that function should never stop Gnus whatever happens;
at least things other than the attachment in question should be
displayed.  Thank you for the patch, but I've modified it in
another way in the Gnus trunk.  It ignores things that are not
2-digit hexadecimal characters that follow `%'s.

Regards,



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

* Re: Make rfc2231-decode-encoded-string more robust
  2008-05-30 10:06 ` Katsumi Yamaoka
@ 2008-05-30 10:25   ` Joao Cachopo
  2008-05-30 10:32     ` Katsumi Yamaoka
  0 siblings, 1 reply; 5+ messages in thread
From: Joao Cachopo @ 2008-05-30 10:25 UTC (permalink / raw)
  To: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> I think that function should never stop Gnus whatever happens;
> at least things other than the attachment in question should be
> displayed.  Thank you for the patch, but I've modified it in
> another way in the Gnus trunk.  It ignores things that are not
> 2-digit hexadecimal characters that follow `%'s.

That's fine, provided that it solves the problem.

I've still not checked your change, but it's not clear from your
description that you deal with the case where the '%' is at the end of
the string.  That is, there is nothing following it.  That's what was
causing the errors that I've seen.

Best regards,
-- 
João Cachopo




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

* Re: Make rfc2231-decode-encoded-string more robust
  2008-05-30 10:25   ` Joao Cachopo
@ 2008-05-30 10:32     ` Katsumi Yamaoka
  2008-05-30 10:40       ` Joao Cachopo
  0 siblings, 1 reply; 5+ messages in thread
From: Katsumi Yamaoka @ 2008-05-30 10:32 UTC (permalink / raw)
  To: Joao Cachopo; +Cc: ding

>>>>> Joao Cachopo wrote:
> Katsumi Yamaoka <yamaoka@jpl.org> writes:

>> It ignores things that are not 2-digit hexadecimal characters
>> that follow `%'s.

> That's fine, provided that it solves the problem.

> I've still not checked your change, but it's not clear from your
> description that you deal with the case where the '%' is at the end of
> the string.  That is, there is nothing following it.  That's what was
> causing the errors that I've seen.

No problem.  Sorry for the vague expressions.  Please see the
following diff, that says what it does exactly. ;-)

http://article.gmane.org/gmane.emacs.gnus.commits/5938



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

* Re: Make rfc2231-decode-encoded-string more robust
  2008-05-30 10:32     ` Katsumi Yamaoka
@ 2008-05-30 10:40       ` Joao Cachopo
  0 siblings, 0 replies; 5+ messages in thread
From: Joao Cachopo @ 2008-05-30 10:40 UTC (permalink / raw)
  To: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> No problem.  Sorry for the vague expressions.  Please see the
> following diff, that says what it does exactly. ;-)
>
> http://article.gmane.org/gmane.emacs.gnus.commits/5938

OK, thanks.

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