Malformed address

Giganews Newsgroups
Subject: Malformed address
Posted by:  Ciaran Costelloe (ccostell…
Date: Fri, 20 Jan 2006

In "procedure TIdEMailAddressItem.SetText(AText: string);" in
IdEmailAddress, there is the following section of code:

              // Strange use. For now raise an exception until a
              // example can be found.
              // Basically, it's formatted as follows:    {Do not
              //    <someg…@domain.example> some-text @ some-text
              // or:
              //    some-text <someg…@domain.example> some-text @
              // where some text may be blank.
              //CC: Note you used to arrive here if the From header in
an email
              //included more than one address (which was subsequently
              //because our code did not parse the From header for
              //addresses.  That may have been the reason for this code.

My application has processed literally millions of emails and only
today has this exception been hit.  The header line that caused it
(with xxx's inserted to preserve anonamimity) is:

To: "Krixxxxxx A." <A.Krxxxxx…>, <Sxxxxxk…>,
        "Korxxxxxxxxxxxer M." <M.Korxxxxxxxxxxx…>,
        "Axxx Sxxxxx \(E-mail\)" <sixxxxxx…>,
        "Ciaran Costelloe \(E-mail\) Costelloe \(E-mail\)"
        "Dexxxf Jaxxxxxxxxi \(E-mail\)" <jxxxxxxxx…>,
        "Hxxxxxk J. Rxxxxxs \(E-mail\)" <r…>,
        "Jxxxxxs Dxxxxt \(E-mail\)" <jxxxxxs.dxxx…>,
        "Sxxxxxxxxxxg R.M." <R.M.Sxxxxxxxxx…>

The last pair of addresses is at fault, they are missing the separating
",".  As a minimum, the above example should be added to the source
code, as an example as to how this unusual exception is triggered.  The
problem for me is that I don't catch this particular exception (really
because it is too difficult to unwind my code) so I am just going to
comment-out the "raise" line, which at least allows me list the emails
in that folder, albeit with the invalid address being displayed (and
any consequent "Reply" presumably failing).

Ultimately, this is another example of junk that nothing can deal with
apart from throwing an exception, but the addition of the above example
may at least give users an example of why the exception gets thrown.