GNU bug report logs - #38200
26.2; sendmail.el needlessly munging headers by inserting backslashes

Previous Next

Package: emacs;

Reported by: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>

Date: Wed, 13 Nov 2019 22:01:01 UTC

Severity: normal

Tags: fixed

Found in version 26.2

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38200 in the body.
You can then email your comments to 38200 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#38200; Package emacs. (Wed, 13 Nov 2019 22:01:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 13 Nov 2019 22:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.2; sendmail.el needlessly munging headers by inserting backslashes
Date: Wed, 13 Nov 2019 16:51:08 -0500 (EST)
Steps:
1. Evaluate the following:
(setq mail-user-agent 'sendmail-user-agent)
(setq send-mail-function 'sendmail-send-it)
2. Hit `C-x m' or `M-x compose-mail'.
3. In the To: header type the following:

"LastName, FirstName I. (CODE-999.9)[CONTRACTOR COMPANY INC]"
	<your_email <at> address.com>

except replace "your_email <at> address.com" with your actual email address.

4. Put "test" in the Subject: header.
5. Add a "Bcc:" header with your actual email address.
6. In the body of the email, put "test".
7. Hit `C-c C-c' or `M-x mail-send' to send the email.

Result:
When you receive the sent email, the To: header of the email will look
like so:

"LastName\, FirstName I. \(CODE-999.9\)\[CONTRACTING COMPANY INC\]"
        <your_email <at> address.com>

It should like like this:

"LastName, FirstName I. (CODE-999.9)[CONTRACTING COMPANY INC]"
        <your_email <at> address.com>

At some point, something in sendmail.el changed between Emacs version
21.2 and 26.2 that resulted in these backslashes being
added. According to RFC822 and other email standards, these
backslashes are not needed. Emacs should not be modifying the headers
of emails needlessly.


In GNU Emacs 26.2 (build 2, x86_64-pc-linux-gnu, X toolkit)
 of 2019-04-12 built on heasarcdev
Windowing system distributor 'Scientific Linux', version 11.0.11704000
System Description:	Scientific Linux release 6.10 (Carbon)

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set [2 times]
Sending...done

Configured using:
 'configure --prefix=/software/usr/contrib
 --exec-prefix=/software/usr/contrib/linux-6.x --with-x-toolkit=athena
 --with-toolkit-scroll-bars=no --with-jpeg=no --with-gif=no
 --with-tiff=no --with-gnutls=no'

Configured features:
XAW3D XPM PNG SOUND GSETTINGS GLIB NOTIFY LIBSELINUX LIBXML2 FREETYPE
XFT ZLIB LUCID X11 XDBE XIM THREADS

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow emacsbug message rmc puny seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs format-spec
rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader mailalias sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair
time-date mule-util tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core term/tty-colors frame cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet
lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese composite charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
minibuffer cl-preloaded nadvice loaddefs button faces cus-face
macroexp files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
threads inotify dynamic-setting font-render-setting x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 95678 7833)
 (symbols 48 19846 1)
 (miscs 40 54 168)
 (strings 32 29174 958)
 (string-bytes 1 769837)
 (vectors 16 14705)
 (vector-slots 8 503996 12136)
 (floats 8 53 115)
 (intervals 56 272 0)
 (buffers 992 9)
 (heap 1024 28666 935))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38200; Package emacs. (Thu, 14 Nov 2019 05:01:02 GMT) Full text and rfc822 format available.

Message #8 received at 38200 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>
Cc: Katsumi Yamaoka <yamaoka <at> jpl.org>, 38200 <at> debbugs.gnu.org
Subject: Re: bug#38200: 26.2; sendmail.el needlessly munging headers by
 inserting backslashes
Date: Thu, 14 Nov 2019 05:59:37 +0100
Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov> writes:

> 1. Evaluate the following:
> (setq mail-user-agent 'sendmail-user-agent)
> (setq send-mail-function 'sendmail-send-it)

[...]

> "LastName\, FirstName I. \(CODE-999.9\)\[CONTRACTING COMPANY INC\]"
>         <your_email <at> address.com>
>
> It should like like this:
>
> "LastName, FirstName I. (CODE-999.9)[CONTRACTING COMPANY INC]"
>         <your_email <at> address.com>

This isn't due to sendmail or anything, but because

(defcustom rfc2047-header-encoding-alist

[...]

    ("\\(Resent-\\)?\\(From\\|Cc\\|To\\|Bcc\\|\\(In-\\)?Reply-To\\|Sender\
\\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\)" . address-mime)

and

		    (when (eq method 'address-mime)
		      (rfc2047-quote-special-characters-in-quoted-strings))

> At some point, something in sendmail.el changed between Emacs version
> 21.2 and 26.2 that resulted in these backslashes being
> added. According to RFC822 and other email standards, these
> backslashes are not needed. Emacs should not be modifying the headers
> of emails needlessly.

I've been perusing the relevant RFCs, but I can't find anything about
having to quote commas and parentheses in quoted-strings.  It's not
disallowed, either -- the RFC says

3.2.1.  Quoted characters

   Some characters are reserved for special interpretation, such as
   delimiting lexical tokens.  To permit use of these characters as
   uninterpreted data, a quoting mechanism is provided.

   quoted-pair     =   ("\" (VCHAR / WSP)) / obs-qp

   Where any quoted-pair appears, it is to be interpreted as the
   character alone.  That is to say, the "\" character that appears as
   part of a quoted-pair is semantically "invisible".

so you can put a backslash in anywhere you want, basically, and it
should make no semantic difference.

But I'm not sure why this was added (in 2006).  Perhaps some MTAs/MUAs
react negatively to having those characters unquoted in strings?  It
looks like this was added by Katsumi, but the changelog doesn't say what
problem it's trying to fix.

Katsumi, do you remember?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38200; Package emacs. (Thu, 14 Nov 2019 07:31:02 GMT) Full text and rfc822 format available.

Message #11 received at 38200 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>, 38200 <at> debbugs.gnu.org
Subject: Re: bug#38200: 26.2; sendmail.el needlessly munging headers by
 inserting backslashes
Date: Thu, 14 Nov 2019 16:30:04 +0900
On Thu, 14 Nov 2019 05:59:37 +0100, Lars Ingebrigtsen wrote:
> But I'm not sure why this was added (in 2006).  Perhaps some MTAs/MUAs
> react negatively to having those characters unquoted in strings?  It
> looks like this was added by Katsumi, but the changelog doesn't say what
> problem it's trying to fix.

> Katsumi, do you remember?

I don't remember why I added the function
`rfc2047-quote-special-characters-in-quoted-strings' at all.  So
do I about `rfc2047-strip-backslashes-in-quoted-strings' either,
sorry.  But as for at least rfc2047-quote-*, it looks surely
needless.  With some brief tests, I verified the address-mime
encoder works without it.  Even if it is necessary for some cases,
it would probably be very rare, so I'd like to remove it now.
May I do that?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38200; Package emacs. (Thu, 14 Nov 2019 07:35:01 GMT) Full text and rfc822 format available.

Message #14 received at 38200 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>, 38200 <at> debbugs.gnu.org
Subject: Re: bug#38200: 26.2; sendmail.el needlessly munging headers by
 inserting backslashes
Date: Thu, 14 Nov 2019 08:34:24 +0100
Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

> I don't remember why I added the function
> `rfc2047-quote-special-characters-in-quoted-strings' at all.  So
> do I about `rfc2047-strip-backslashes-in-quoted-strings' either,
> sorry.

I seem to vaguely recall there perhaps being a problem with things
like

From: "Foo, Bar" <foo <at> zot.com>, zot <at> foo.com

being tokenized into three email addresses

Foo
Bar <foo <at> zot.com>
zot <at> foo.com

But on the other hand, if there's anything that broken out there, you'd
think that adding a backslash before the comma wouldn't help, either.

> But as for at least rfc2047-quote-*, it looks surely
> needless.  With some brief tests, I verified the address-mime
> encoder works without it.  Even if it is necessary for some cases,
> it would probably be very rare, so I'd like to remove it now.
> May I do that?

Sure, go ahead.  If there's any interoperability problems here, we'll
find out.  But I think it's pretty unlikely.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38200; Package emacs. (Thu, 14 Nov 2019 08:06:02 GMT) Full text and rfc822 format available.

Message #17 received at 38200 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>, 38200 <at> debbugs.gnu.org
Subject: Re: bug#38200: 26.2; sendmail.el needlessly munging headers by
 inserting backslashes
Date: Thu, 14 Nov 2019 17:05:34 +0900
[Message part 1 (text/plain, inline)]
On Thu, 14 Nov 2019 08:34:24 +0100, Lars Ingebrigtsen wrote:
> I seem to vaguely recall there perhaps being a problem with things
> like

> From: "Foo, Bar" <foo <at> zot.com>, zot <at> foo.com

> being tokenized into three email addresses

> Foo
> Bar <foo <at> zot.com>
> zot <at> foo.com

> But on the other hand, if there's anything that broken out there, you'd
> think that adding a backslash before the comma wouldn't help, either.

Sure.  Mail agents do not know what backslashes like to do.

> Katsumi Yamaoka <yamaoka <at> jpl.org> writes:
>> But as for at least rfc2047-quote-*, it looks surely
>> needless.  With some brief tests, I verified the address-mime
>> encoder works without it.  Even if it is necessary for some cases,
>> it would probably be very rare, so I'd like to remove it now.
>> May I do that?

> Sure, go ahead.  If there's any interoperability problems here, we'll
> find out.  But I think it's pretty unlikely.

Done in master.  Thanks.  Ed, a patch for Emacs 26.2 is attached.

Regards,
[remove-rfc2047-quote-special-characters-in-quoted-strings.patch.gz (application/x-gunzip, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38200; Package emacs. (Thu, 14 Nov 2019 08:12:02 GMT) Full text and rfc822 format available.

Message #20 received at 38200 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>, 38200 <at> debbugs.gnu.org
Subject: Re: bug#38200: 26.2; sendmail.el needlessly munging headers by
 inserting backslashes
Date: Thu, 14 Nov 2019 09:10:52 +0100
Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

> Done in master.  Thanks.  Ed, a patch for Emacs 26.2 is attached.

[...]

> -(defun rfc2047-quote-special-characters-in-quoted-strings (&optional
> -							   encodable-regexp)
> -  "Quote special characters with `\\'s in quoted strings.
> -Quoting will not be done in a quoted string if it contains characters
> -matching ENCODABLE-REGEXP or it is within parentheses."

I'm not sure removing the function is the right thing to do -- it may be
used by third-party code.  So we should just obsolete it and then remove
it in (say) Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38200; Package emacs. (Thu, 14 Nov 2019 08:31:03 GMT) Full text and rfc822 format available.

Message #23 received at 38200 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>, 38200 <at> debbugs.gnu.org
Subject: Re: bug#38200: 26.2; sendmail.el needlessly munging headers by
 inserting backslashes
Date: Thu, 14 Nov 2019 17:29:45 +0900
On Thu, 14 Nov 2019 09:10:52 +0100, Lars Ingebrigtsen wrote:
>> -(defun rfc2047-quote-special-characters-in-quoted-strings (&optional
>> -							   encodable-regexp)

> I'm not sure removing the function is the right thing to do -- it may be
> used by third-party code.  So we should just obsolete it and then remove
> it in (say) Emacs 29.

Done.  Thanks again.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38200; Package emacs. (Fri, 15 Nov 2019 01:12:01 GMT) Full text and rfc822 format available.

Message #26 received at 38200 <at> debbugs.gnu.org (full text, mbox):

From: Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov>
To: 38200 <at> debbugs.gnu.org
Subject: Re: bug#38200: 26.2; sendmail.el needlessly munging headers by
 inserting backslashes
Date: Thu, 14 Nov 2019 20:05:14 -0500 (EST)
I have applied the patch to my installation of 26.2, and I can confirm
that the backslashes are no longer inserted into the To: header.

Thank you, Lars and Katsumi, for so quickly investigating and
resolving this!

Regards,
Ed




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 15 Nov 2019 10:08:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 38200 <at> debbugs.gnu.org and Ed Sabol <esabol <at> milkyway.gsfc.nasa.gov> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 15 Nov 2019 10:08:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 13 Dec 2019 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 191 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.