From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.devel Subject: rfc2047-decode-region Date: Sat, 31 Dec 2011 21:48:44 +0900 Message-ID: <87obuoewk3.fsf@uwakimon.sk.tsukuba.ac.jp> References: <83wr9drqyx.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: dough.gmane.org 1325335752 22058 80.91.229.12 (31 Dec 2011 12:49:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 31 Dec 2011 12:49:12 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 31 13:49:09 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RgyN2-0005gt-Lj for ged-emacs-devel@m.gmane.org; Sat, 31 Dec 2011 13:49:08 +0100 Original-Received: from localhost ([::1]:38076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgyN2-0008Dt-9r for ged-emacs-devel@m.gmane.org; Sat, 31 Dec 2011 07:49:08 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:59510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgyMz-0008Dn-So for emacs-devel@gnu.org; Sat, 31 Dec 2011 07:49:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgyMz-0000Gf-1j for emacs-devel@gnu.org; Sat, 31 Dec 2011 07:49:05 -0500 Original-Received: from mgmt2.sk.tsukuba.ac.jp ([130.158.97.224]:59125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgyMx-0000GG-Ki; Sat, 31 Dec 2011 07:49:03 -0500 Original-Received: from uwakimon.sk.tsukuba.ac.jp (uwakimon.sk.tsukuba.ac.jp [130.158.99.156]) by mgmt2.sk.tsukuba.ac.jp (Postfix) with ESMTP id 9A19F9707AA; Sat, 31 Dec 2011 21:48:44 +0900 (JST) Original-Received: by uwakimon.sk.tsukuba.ac.jp (Postfix, from userid 1000) id 92F901A3172; Sat, 31 Dec 2011 21:48:44 +0900 (JST) In-Reply-To: <83wr9drqyx.fsf@gnu.org> X-Mailer: VM undefined under 21.5 (beta31) "ginger" 2dbefd79b3d3 XEmacs Lucid (x86_64-unknown-linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 130.158.97.224 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:147092 Archived-At: 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).