Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Saving MIME parts with RFC2047 encoded names
@ 2003-04-09 17:12 Gustavo Chaves
  2003-04-09 18:24 ` Jesper Harder
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo Chaves @ 2003-04-09 17:12 UTC (permalink / raw)


Hi,

I use Gnus v5.9.0 with Emacs 21.1.1.  I use it to read mail for about
two years but I've never used News before.  Bear with me, please.

I often receive messages with files attached which contain accented
characters in their names.  These names are encoded as per RFC2047.  I
perused the Gnus sources and found that the mm-save-part function is
the one actually saving the part as a file.  I made a few modification
to it in order to decode the attachment names like this (changed/added
lines prefixed with a '>>'):

(defun mm-save-part (handle)
  "Write HANDLE to a file."
  (let* ((name (mail-content-type-get (mm-handle-type handle) 'name))
	 (filename (mail-content-type-get
		    (mm-handle-disposition handle) 'filename))
	 file)
>>  (when name
>>    (setq name (rfc2047-decode-string name)))
    (when filename
>>    (setq filename (rfc2047-decode-string
>>                    (file-name-nondirectory filename))))
    (setq file
	  (read-file-name "Save MIME part to: "
			  (expand-file-name
			   (or filename name "")
			   (or mm-default-directory default-directory))))
    (setq mm-default-directory (file-name-directory file))
    (when (or (not (file-exists-p file))
	      (yes-or-no-p (format "File %s already exists; overwrite? "
				   file)))
      (mm-save-part-to-file handle file))))

Is this a proper fix for it or is there an oficial way to do it?

Thanks,

Gustavo.


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

* Re: Saving MIME parts with RFC2047 encoded names
  2003-04-09 17:12 Saving MIME parts with RFC2047 encoded names Gustavo Chaves
@ 2003-04-09 18:24 ` Jesper Harder
  0 siblings, 0 replies; 2+ messages in thread
From: Jesper Harder @ 2003-04-09 18:24 UTC (permalink / raw)


Gustavo Chaves <gustavo@cpqd.com.br> writes:

> I often receive messages with files attached which contain accented
> characters in their names.  These names are encoded as per RFC2047.

FWIW, this isn't standards compliant -- they should be encoded according
to RFC 2231.

> Is this a proper fix for it or is there an oficial way to do it?

It's fixed in the following way in the development version of Gnus, if
you're interested:

  (defalias 'mail-header-parse-content-type 'rfc2231-parse-qp-string)
  (defalias 'mail-header-parse-content-disposition 'rfc2231-parse-qp-string)

  (defun rfc2231-parse-qp-string (string)
    "Parse QP-encoded string using `rfc2231-parse-string'.
  N.B.  This is in violation with RFC2047, but it seem to be in common use."
    (rfc2231-parse-string (rfc2047-decode-string string)))


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

end of thread, other threads:[~2003-04-09 18:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-09 17:12 Saving MIME parts with RFC2047 encoded names Gustavo Chaves
2003-04-09 18:24 ` Jesper Harder

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