[ic] email-raw usertag broken for Net::SMTP FIX

Mike Heins mike at perusion.com
Sun May 1 22:21:31 EDT 2005

Quoting Peter (peter at pajamian.dhs.org):
> On 05/01/05 07:30, Mike Heins wrote:
> >Quoting Peter (peter at pajamian.dhs.org):
> >
> >>On 04/30/05 20:04, Mike Heins wrote:
> >>
> >>>>One thing I failed to mention before is that my patch fails to account 
> >>>>for the possibility of folded headers.  I didn't think too much of it 
> >>>>because I don't anticipate anyone using the email-raw tag to send 
> >>>>emails out with folded headers, but if you want to make it work with 
> >>>>then an additional regexp to unfold them should fix it.  Something like 
> >>>>the following before the split line should do it:
> >>>>
> >>>>$headers =~ s/\r?\n([ \t])/$1/s;
> >>>
> >>>
> >>>It would seem to make sense to account for it. Can't we do so simply by
> >>>joining the @header array with a \n without stripping the headers
> >>>in send_mail?
> >>
> >>I never bothered to look fully into the details of how send_mail works 
> >>with Net::SMTP.  That said...
> >>
> >>When I patched email-raw I looked at send_mail to see how to use it and 
> >>it checks the first arg to see if it's a ref and if it is it assumes 
> >>that the first arg is an array ref of all the headers and the second arg 
> >>the email body.  If the first arg is not a ref then it is assumed to be 
> >>the To: recipient for the email.  so by joining them as yuou suggest 
> >>would just make send_mail assume that all those headers are the 
> >>recipient and won't work.
> >
> >
> >I did mean in send_mail().
> >
> >
> >>If you want to hack up send_mail to work 
> >>differently then be my guest, but i would want to caution against doing 
> >>so in a way that might break existing functionality.
> >
> >
> >That is always the worry. 8-) But I think we can safely do this:
> >
> >       for(my $i = $#$head; $i > 0; $i--) {
> >           if($head->[$i] =~ /^\s/) {
> >               my $new = splice @$head, $i, 1;
> >               $head->[$i - 1] .= "\n$new";
> >           }
> >       }
> That should work, but it doesn't make sense to me to do it that way. 
> Let me explain...
> $head is supposed to be an array ref of individual headers.

It is? 8-) I am not sure that is true. I believe I wrote the code,
and I don't know that I defined that to be what it was. In fact, I deplore
the way it is and consider it some of the worst code I have ever produced
that has lived a long time (I guess it is tied with order profiles and
the log_transaction setup). Even just now found a bug where the valid
"Reply-To" header would not be recognized.

> It would 
> seem to me that passing parts of headers in individual elements would be 
> a broken usage of the array.  It doesn't make sense to fix this in 
> send_mail as send_mail should not be respoonsible for fixing the broken 
> array that is passed to it from other functions.  send_mail should be 
> able to expect that the array passed to it is good.  So it makes more 
> sense to me to fix it in the email-raw usertag (and other usertags and 
> functions that do something similar) so they don't pass a broken array 
> to send_mail.

Hmm. I guess I just disagree. Again, we get into the possibility of
a number of different versions of header-canonicalization code.

I try to be of the "be strict in what you send, but tolerant in what
you accept" school, and it seems to me that send_mail should be pretty
tolerant if it is to be the main facility for sending mail -- particularly
if we do what I think should be done and add a "raw" option to that and
make the email tag just a wrapper around send_mail.

Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Fast, reliable, cheap.  Pick two and we'll talk.  -- unknown

More information about the interchange-users mailing list