[gnu.emacs.bug] bug in define-mail-alias

mjab@THINK.COM (09/22/88)

The function define-mail-alias in emacs version 18.49.20 is
wrong.  It incorrectly assumes that blanks in a mail address are
meant to separate mail addresses.  It adds commas after every
word of a multi-word mail address which creates havoc if
build-mail-aliases is used to create aliases from a .mailrc file
which contains many such addresses.

The problem arises because of addresses in the form

lots of words <real-adress@place.domain>

This form of addressing comes up very frequently when mailing to
institutions (like the military or IBM) which restrict access to
electonic mail to whole departments rather than individuals.

The required fix is to replace define-mail-alias with the
following:


;;; This definition fails to trash addresses in the form 
;;; "Roland H. Pesch <saxony!pesch@sun.com>"  The way it is defined
;;; in /public/gnu/dist/lisp/mailalias.el is completely wrong.
;;; -Michael Berry Wed Sep 14 1988


(defun define-mail-alias (name definition)
  "Define NAME as a mail-alias that translates to DEFINITION."
  (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
  ;; Read the defaults first, if we have not done so.
  (if (eq mail-aliases t)
      (progn
	(setq mail-aliases nil)
	(if (file-exists-p "~/.mailrc")
	    (build-mail-aliases))))
  ;removed code wich mistakenly inserted commas -mjab Wed Sep 14 1988
      (setq mail-aliases (cons (cons name definition) mail-aliases)))

I have tested this patch.  With it, aliases like the following
one are properly translated.


alias x3j3   Jeanne Adams -NCAR <jeanne%hao.ucar.edu@relay.cs.net>, Bob Allison -Microsoft <microsoft!bobal@uunet.uu.net>, Michael Berry -Thinking Machines <mjab@Think.COM>, Walter Brainerd -Unicomp <brainerd%unmvax.unm.edu@relay.cs.net>, Carl Burch -HP <
cdb%hpda@hplabs.hp.com>, Gary Campbell - Sun <gcampbell@sun.com>, Tim Dodd -Modcomp <mtune!codas!novavax!modcom!tim@uunet.uu.net>, Miles Ellis -Oxford <ctcmiles%uk.ac.oxford.vax@nss.cs.ucl.ac.uk>, Kevin Harris -DEC <harris%tle.dec@decwrl.dec.com>, Dick He
ndrickson -ETA <rhendric%rah.sunfun.eta.com@relay.cs.net>, Kurt Hirchert -Univ of Il <hirchert@newton.ncsa.uiuc.edu>, Andy Johnson -Prime <andyj%enx.prime.com@relay.cs.net>, Henry Katz -DOD <katz%umbc.bitnet@cunyvm.cuny.edu>, Sharon Lammers -Cray <gatech!
mcdchg!motmpl!hall!floral!sml@rutgers.edu>, Rochelle Lauer -DECUS <lauerc%yalehep.bitnet@cunyvm.cuny.edu>, Bill Leonard -Harris <bill%ssd.harris.com@relay.cs.net>, Neldon Marshall -INEL <egg-id!ise01!nmh@uunet.uu.net>, Jeanne Martin -LLNL <martin@lll-crg.
llnl.gov>, Alex Marusak -LANL <alm@lanl.gov>, Mike Metcalf -CERN <metcalf%cernvm.bitnet@cunyvm.cuny.edu>, Geoff Millard -EPCL <G.Millard%edinburgh.ac.uk@nss.cs.ucl.ac.uk>, Len Moss -SLAC <ljm%slacvm.bitnet@cunyvm.cuny.edu>, Dan Pearl -Masscomp <masscomp!d
anny@uunet.uu.net>, Ivor Philips -Boeing CS <philips@boeing.com>, Rich Ragan -CDC <ragan%cdccentr.bitnet@cunyvm.cuny.edu>, L Schonfelder-U Liverpool <jls%liverpool.ac.uk@nss.cs.ucl.ac.uk>, Paul Sinclair -Telesoft <telesoft!pls@ucsd.edu>, Brian Smith -ANL 
<smith@anl-mcs.arpa>, Presley Smith -Convex <convex!psmith@uunet.uu.net>, Sunnie Sund -SHARE <sunnie%slacvm.bitnet@cunyvm.cuny.edu>, Richard Swift -Alliant <alliant!swift@uunet.uu.net>, Andrew Tait - Amdahl <decwrl!amdahl!adt10@uunet.uu.net>, Brian Thomps
on-Concurrent <petsd!blt@uunet.uu.net>, Jerry Wagener - AMOCO <apctrc!jlw@uunet.uu.net>, Tammy Yan -Data General <mcnc!rti!dg-rtp!tammy@uunet.uu.net>


=============================================
Michael J. A. Berrry

Internet: mjab@think.com
uucp:     {harvard, ihnp4, seismo}!think!mjab
=============================================

mjab@THINK.COM (09/30/88)

   Date: Wed, 21 Sep 88 18:34:20 EDT
   From: rms@wheaties.ai.mit.edu (Richard Stallman)

   The evidence available to me seems to say that spaces do separate
   recipient names in mail aliases.  So I won't change Emacs unless I get
   clear evidence that they are not *supposed* to do so.  Sorry.

   ....

   Date: Fri, 23 Sep 88 17:11:02 EDT
   From: rms@wheaties.ai.mit.edu (Richard Stallman)

       Please take a look at rfc822.

   It is not clear to me that rfc822 is the spec for the alias command.

Here is a little more information on why I think the current
behavior of emacs when building aliases is in error.  While
rfc822 is not directly a spec for the alias command, it is a spec
for internet mail addresses.  The purpose of aliases is to allow
me to use a short mnemonic name for one or more internet mail
aliases. It follows that if I say 

alias friends valid-list-of-mail-addresses

I should be able to type 

TO: friends

or

CC: friends

to have mail sent to the list of valid addresses.  Since valid
internet addresses often contain whitespace (as specified in
rfc822), the emacs function define-mail-alias should respect the
whitespace in a valid addresse and not insert commas which turn a
single valid address into several invalid ones.

The following is the relevant excerpt from rfc822.  Note that
address -> mailbox -> phrase route-addr -> phrase <[route] addr-spec>
It is the "phrase" which is being seen by emacs as addresses when
it should not be.

     Standard for ARPA Internet Text Messages


     6.  ADDRESS SPECIFICATION

     6.1.  SYNTAX

     address     =  mailbox                      ; one addressee
                 /  group                        ; named list

     group       =  phrase ":" [#mailbox] ";"

     mailbox     =  addr-spec                    ; simple address
                 /  phrase route-addr            ; name & addr-spec

     route-addr  =  "<" [route] addr-spec ">"

     route       =  1#("@" domain) ":"           ; path-relative

     addr-spec   =  local-part "@" domain        ; global address

     local-part  =  word *("." word)             ; uninterpreted
                                                 ; case-preserved

     domain      =  sub-domain *("." sub-domain)

     sub-domain  =  domain-ref / domain-literal

     domain-ref  =  atom                         ; symbolic reference


Here, again, is my proposed definition for this function:

(defun define-mail-alias (name definition)
  "Define NAME as a mail-alias that translates to DEFINITION."
  (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
  ;; Read the defaults first, if we have not done so.
  (if (eq mail-aliases t)
      (progn
	(setq mail-aliases nil)
	(if (file-exists-p "~/.mailrc")
	    (build-mail-aliases))))
  ;removed code wich mistakenly inserted commas -mjab Wed Sep 14 1988
      (setq mail-aliases (cons (cons name definition) mail-aliases)))


=============================================
Michael J. A. Berrry

Internet: mjab@think.com
uucp:     {harvard, ihnp4, seismo}!think!mjab
=============================================

kayvan@APPLE.COM (09/30/88)

Come on, man. I don't see why you can't live with:

   alias hodedo one-man@machine, two-man@machine2, three-man@machine3

Instead of the weird and woolly:

   alias hodedo Khan N. Noonan <one-man@machine>, John Doe <two-man@machine>,
	Howdy Doody <three-man@machine3>

Creeping featurism indeed!!

I opt for simplicity.

			---Kayvan

P.S. Hello, Richard!

rlk@THINK.COM (Robert L. Krawitz) (09/30/88)

Well, for one it's easier to read the addresses in the outgoing mail
when names are included.  Also, it looks offhand like an address like

<foo bar@baz.quux>

is a legal address.  For three, why shouldn't emacs follow RFC822?

I think Michael's change is a good one.

harvard >>>>>>  |		Robert Krawitz <rlk@think.com>
bloom-beacon >  |think!rlk
topaz >>>>>>>>  .		rlk@a.HASA.disorg

shap@polya.Stanford.EDU (Jonathan S. Shapiro) (09/30/88)

In article <8809291815.AA10511@medusa.think.com> mjab@THINK.COM writes:
>Since valid
>internet addresses often contain whitespace (as specified in
>rfc822), the emacs function define-mail-alias should respect the
>whitespace in a valid addresse and not insert commas which turn a
>single valid address into several invalid ones.

Socrates is a man
I am a man
Therefore I am socrates.

Spaces are supposed to be valid recipient *separators.* It has nothing
to do with the internet mail standards. There *are* other mailers in
the world.

If you need to have spaces honored, the correct solution is to quote
the address:

	"fred foobar@frob.arpa"

or to use a backslash in the obvious place.  It is true that emacs
should honor both of these. I do not know if it does.

A request:

Mail is complicated enough already.  If you don't know, *ask.* Don't
obfuscate by promulgating information that is ill considered or simply
silly.  To put that recommendation in a positive light, a better
posting would have been:

	Why are spaces not honored as parts of addresses in an aliases
	file when RFC822 says they are a valid part of a recipient
	address?

Jon Shapiro