On Sun, 23 Oct 2005, Kalle Olavi Niemitalo wrote:
> Daniel Rall <email@example.com> writes:
> > On Thu, 20 Oct 2005, Kalle Olavi Niemitalo wrote:
> >> Also, if $mail_from contains multibyte characters, then \Q seems
> >> to quote each byte if Perl doesn't know the character encoding;
> >> but at least Bash 3.0 happily removes the backslashes again.
> > Sounds like an important concern. Does Perl always use bash, or does it
> > use whichever shell an user has setup?
> According to perldoc -f exec, it uses "/bin/sh -c" on Unix.
> That is not user-specific, but neither is it always Bash.
Okay. And since /bin/sh isn't always bash, we probably shouldn't rely on
that behavior (though other shells may do the same thing).
> > Can the envelop sender address even contain multibyte characters?
> Apparently not at the SMTP level, according to the definitions of
> "Reverse-path" in RFC 2821 and "qcontent" in RFC 2822. The MIME
> encodings of RFC 2047 do not seem to be allowed there, either.
Then, we can ignore this benefit of the \Q...\E approach.
> >> Another possibility might be to put the strings as separate
> >> arguments in the open call:
> >> if open(SENDMAIL, "|-", $command, "-f", $mail_from,
> >> split(/\s+/, $userlist))
> > I like the look of this better (I'm unfamiliar with the quoting technique
> > you used above).
> Note that the arguments here will not be parsed by a shell, so
> e.g. spaces in $command will be taken as part of the file name,
> and quotes in $userlist will not protect spaces (so it would be
> better to use @email_addresses directly).
*nod* That's exactly the behavior that we want.
> And I wonder what would happen on Windows, where the command line
> is a single string rather than a list of strings, and programs
> rarely document how their arguments should be quoted.
> > What versions of Perl would this not work on, and should we care?
> It works in Perl 5.7.1 and later, according to perl571delta:
> # o The list form of "open" is now implemented for pipes
> # (at least on UNIX):
> # open($fh,"-│", ’cat’, ’/etc/motd’)
> # creates a pipe, and runs the equivalent of exec(’cat’,
> # ’/etc/motd’) in the child process.
> The $] test at the beginning of commit-email.pl.in tries to
> support versions older than 5.6, too.
Is there any way to get this behavior with Perl 5.6 while avoiding quoting
of unrecognized characters (or would that even come up as a problem, with
them not allowed in the sender envelop)?
To unsubscribe, e-mail: firstname.lastname@example.org
For additional commands, e-mail: email@example.com
Received on Mon Oct 24 21:52:23 2005