all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* RMAIL, multipart MIME-type, charset fix
@ 2003-09-28 21:56 Alexander Pohoyda
  2003-09-29  6:10 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Pohoyda @ 2003-09-28 21:56 UTC (permalink / raw)


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

Hi all,

Current behaviour: RMAIL searches the message header for the
Content-Type header field with text/plain type, and tries to find out
the MIME-charset used (charset attribute).
That's nice, but if the message comes in multipart type, no such
header field is found, thus the undecided coding system is used
instead.

In other words, RMAIL does not handle the multipart MIME-type.

While I'm working on the correct solution (implementing missing RFC
2045, 2046, 2047 functionality), attached patch solves the problem
today. It tries to find the wanted header field in the whole message,
if it was not found in the message header.
This should work for 98% of cases, I suppose.

Thanks for taking a look. Diff against the current CVS.

-- 
Alexander Pohoyda <alexander.pohoyda@gmx.net>
PGP Key fingerprint: 7F C9 CC 5A 75 CD 89 72  15 54 5F 62 20 23 C6 44


[-- Attachment #2: rmail.el.diff --]
[-- Type: text/x-patch, Size: 1970 bytes --]


--- /workspace/emacs/lisp/mail/rmail.el	Wed Sep  3 22:11:40 2003
+++ /usr/local/share/emacs/21.3.50/lisp/mail/rmail.el	Sun Sep 28 23:27:45 2003
@@ -1703,13 +1703,20 @@
 		       (not rmail-enable-multibyte)
 		       (let ((mime-charset
 			      (if (and rmail-decode-mime-charset
-				       (save-excursion
-					 (goto-char start)
-					 (search-forward "\n\n" nil t)
-					 (let ((case-fold-search t))
-					   (re-search-backward
-					    rmail-mime-charset-pattern
-					    start t))))
+				       (or
+					(save-excursion
+					  (goto-char start)
+					  (search-forward "\n\n" nil t)
+					  (let ((case-fold-search t))
+					    (re-search-backward
+					     rmail-mime-charset-pattern
+					     start t)))
+					;; Try to search the whole message
+					(save-excursion
+					  (let ((case-fold-search t))
+					    (re-search-backward
+					     rmail-mime-charset-pattern
+					     start t)))))
 				  (intern (downcase (match-string 1))))))
 			 (rmail-decode-region start (point) mime-charset)))))
 	       ;; Add an X-Coding-System: header if we don't have one.
@@ -1843,13 +1850,20 @@
 		   (not rmail-enable-multibyte)
 		   (let ((mime-charset
 			  (if (and rmail-decode-mime-charset
-				   (save-excursion
-				     (goto-char start)
-				     (search-forward "\n\n" nil t)
-				     (let ((case-fold-search t))
-				       (re-search-backward
-					rmail-mime-charset-pattern
-					start t))))
+				   (or
+				    (save-excursion
+				      (goto-char start)
+				      (search-forward "\n\n" nil t)
+				      (let ((case-fold-search t))
+					(re-search-backward
+					 rmail-mime-charset-pattern
+					 start t)))
+				    ;; Try to search the whole message
+				    (save-excursion
+				      (let ((case-fold-search t))
+					(re-search-backward
+					 rmail-mime-charset-pattern
+					 start t)))))
 			      (intern (downcase (match-string 1))))))
 		     (rmail-decode-region start (point) mime-charset)))
 	       (save-excursion

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

_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs

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

* Re: RMAIL, multipart MIME-type, charset fix
  2003-09-28 21:56 RMAIL, multipart MIME-type, charset fix Alexander Pohoyda
@ 2003-09-29  6:10 ` Eli Zaretskii
  2003-09-29 10:10   ` Alexander Pohoyda
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2003-09-29  6:10 UTC (permalink / raw)
  Cc: bug-gnu-emacs

> Date: Sun, 28 Sep 2003 23:56:29 +0200 (CEST)
> From: Alexander Pohoyda <alexander.pohoyda@gmx.net>
> 
> In other words, RMAIL does not handle the multipart MIME-type.

Right.

> While I'm working on the correct solution (implementing missing RFC
> 2045, 2046, 2047 functionality), attached patch solves the problem
> today. It tries to find the wanted header field in the whole message,
> if it was not found in the message header.
> This should work for 98% of cases, I suppose.

Is this supposed to work for messages that specify different charsets
for different parts?  Or is it supposed to pick up just the charset
specification of the last part of the message?

Anyway, thanks for working on this.  Multipart MIME messages handling
is about my only serious gripe about RMAIL.

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

* Re: RMAIL, multipart MIME-type, charset fix
  2003-09-29  6:10 ` Eli Zaretskii
@ 2003-09-29 10:10   ` Alexander Pohoyda
  2003-09-29 16:26     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Pohoyda @ 2003-09-29 10:10 UTC (permalink / raw)
  Cc: bug-gnu-emacs

> > While I'm working on the correct solution (implementing missing RFC
> > 2045, 2046, 2047 functionality), attached patch solves the problem
> > today. It tries to find the wanted header field in the whole message,
> > if it was not found in the message header.
> > This should work for 98% of cases, I suppose.
> 
> Is this supposed to work for messages that specify different charsets
> for different parts?

Unfortunately, no. The patch to fix this will be much bigger.
While theoretically possible, I have never seen such a case before.

>                       Or is it supposed to pick up just the charset
> specification of the last part of the message?

Yes, you are right. It is supposed to pick up the charset of the
last text/plain bodypart, which is the 98% I mentioned.
The most common mails I have problem with are GPG signed
messages, and this simple patch solves the problem for me.

-- 
Alexander Pohoyda <alexander.pohoyda@gmx.net>
PGP Key fingerprint: 7F C9 CC 5A 75 CD 89 72
 15 54 5F 62 20 23 C6 44

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

* Re: RMAIL, multipart MIME-type, charset fix
  2003-09-29 10:10   ` Alexander Pohoyda
@ 2003-09-29 16:26     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2003-09-29 16:26 UTC (permalink / raw)
  Cc: bug-gnu-emacs

> Date: Mon, 29 Sep 2003 12:10:46 +0200 (MEST)
> From: "Alexander Pohoyda" <alexander.pohoyda@gmx.net>
> > 
> > Is this supposed to work for messages that specify different charsets
> > for different parts?
> 
> Unfortunately, no. The patch to fix this will be much bigger.
> While theoretically possible, I have never seen such a case before.

I did.  Gnus tends to produce such mails when the original text
contains several incompatible character sets (i.e. characters that
cannot be safely encoded using a single coding system).

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

end of thread, other threads:[~2003-09-29 16:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-28 21:56 RMAIL, multipart MIME-type, charset fix Alexander Pohoyda
2003-09-29  6:10 ` Eli Zaretskii
2003-09-29 10:10   ` Alexander Pohoyda
2003-09-29 16:26     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.