unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stephen J. Turnbull" <stephen@xemacs.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: rfc2047-decode-region
Date: Sat, 31 Dec 2011 21:48:44 +0900	[thread overview]
Message-ID: <87obuoewk3.fsf@uwakimon.sk.tsukuba.ac.jp> (raw)
In-Reply-To: <83wr9drqyx.fsf@gnu.org>

Eli Zaretskii writes:
 > This function accepts an optional ADDRESS-MIME argument, which is
 > described in the doc string thusly:
 > 
 >   If ADDRESS-MIME is non-nil, strip backslashes which precede characters
 >   other than `"' and `\' in quoted strings.
 > 
 > This gives absolutely no information about when to use this option and
 > why.

It's all in RFC 5322.  Doesn't everybody know that by heart? ;-)

 > The emacs-mime manual doesn't even mention this argument.

A "quoted string" in RFC 5322 is a string of printing ASCII
characters, excluding the backslash and the double quote, plus SPC,
TAB, and CRLF pairs enclosed in double quotes.  The backslash is a
no-op (ie, treated as not present) in such a quoted string except when
followed immediately by another backslash or a double quote.  The CRLF
is also a no-op (ie, used for folding).

Quoted strings are treated as "atoms", which are mostly of interest in
address parsing, thus the name, I guess.  MIME doesn't have anything
to do with it AFAICS; this definition is from the RFC 822 family.
Probably a better name would be "canonicalize-quoted-strings", since
it's not actually decoding them (that would involve translating
quoted-pairs of \\ and \" to \ and " respectively, and stripping out
CRLF pairs).

I think this behavior is actually broken, since rfc2047-encode-region
cannot know if any given string has been treated with ADDRESS-MIME
(and so the \\ and \" pairs should not be quoted to \\\\ and \\\"), or
not (in which ase they should be so quoted).  It probably doesn't
matter, though: uless somebody wants to deliberately screw you up
those pairs are very unlikely to occur in a raw string.

I would assume that this argument should be non-nil when decoding a
header field which is parsed into atoms, such as To or From.  Possibly
this would apply to Message-ID and References as well (in messages
conforming to RFC 5322 and maybe 2822, but in 822 References and
In-Reply-To were just unstructured text).



  reply	other threads:[~2011-12-31 12:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-31 10:11 rfc2047-decode-region Eli Zaretskii
2011-12-31 12:48 ` Stephen J. Turnbull [this message]
2011-12-31 14:32   ` rfc2047-decode-region Eli Zaretskii
2012-01-02 13:18     ` rfc2047-decode-region Stephen J. Turnbull
2012-01-02 17:33       ` rfc2047-decode-region Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87obuoewk3.fsf@uwakimon.sk.tsukuba.ac.jp \
    --to=stephen@xemacs.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.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.
Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).