Daniel Rall <firstname.lastname@example.org> 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.
> 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.
>> 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).
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.
>> but perhaps that doesn't work on all Perl versions you want to
> print "Happy not to be a Perl hacker ;-P\n";
> 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.
Received on Sun Oct 23 08:41:32 2005
- application/pgp-signature attachment: stored