[rt-devel] Re: [rt-users] Bug in 'From' processing in 2.0.12?

Smylers smylers at gbdirect.co.uk
Thu Mar 28 04:47:08 EST 2002


Yesterday Phil Oester wrote:

> That doesn't help, as it appears to just fixup 'Real Name' fields which
> have email addresses in them.
>
> The problem here (I believe) is caused by Sendmail mangling the 'From'
> field if it has quotes.

'Sendmail' isn't mangling the field; the field is actually broken
according to RFC 2822.

> ... a real name of:
>
> 	"Last, First"
>
> Gets converted by SendEmail.pm to:
>
> 	From: ""Last, First" via RT"

If certain punctuation characters appear in the display name portion of
an e-mail address, then the entire display name must be quoted.  So this
is allowed:

  $friendly_name = 'Homer Simpson';

  Homer Simpson <homer at example.org>

But the dot here requires the quote marks:

  $friendly_name = 'Homer J. Simpson';

  "Homer J. Simpson" <homer at example.org>

'RT' is quoting the display name after it's added " via RT".  This
should never do any harm -- quoting display names that don't have any
punctuation characters in them, so either of these are fine:

  "Homer Simpson via RT" <homer at example.com>
  "Homer J. Simpson via RT" <homer at example.com>

Trouble is if $friendly_name has a quote mark in it already:

  $friendly_name = '"Homer J. Simpson"';

'RT' is then mangling this into:

  ""Homer J. Simpson" via RT" <homer at example.com>

Ooops.  Now we have an empty comment at the beginning "" then we have
Homer unquoted, which 'Sendmail' will treat as a local address and turn
into Homer at localhost.  That isn't a 'Sendmail' but -- unquoted
single-words are _supposed_ to be local addresses!

> So - aside from trying to fix sendmail (hopeless), I think the following
> snippet will work :
>
> -      $self->SetHeader('From', "\"$friendly_name via RT\" <$replyto>");
> +      $self->SetHeader('From', "$friendly_name via RT <$replyto>");

That still won't work.  A string with a dot but no quotes:

  $friendly_name = 'Homer J. Simpson';

  Homer J. Simpson via RT <homer at example.com>

That unquoted dot isn't permitted in the address.

But even in the case where $friendly_name already had quotes in it:

  $friendly_name = '"Homer J. Simpson"';

  "Homer J. Simpson" via RT <homer at example.com>

That isn't permitted, because only part of the display name is quoted --
either all or none of it should be.

So SendMail.pm _should_ be adding quote marks round the entire display
name.  The problem is with $friendly_name already having quote marks in
it.  I'd've thought that keeping the original line is more appropriate,
just removing internal quotes first:

      $friendly_name =~ tr/"//d;
      $self->SetHeader('From', "\"$friendly_name via RT\" <$replyto>");

Smylers
-- 
GBdirect
http://www.gbdirect.co.uk/






More information about the rt-users mailing list