develooper Front page | perl.perl5.porters | Postings from December 2004

Re: [perl #33173] shellwords.pl and tainting

Thread Previous | Thread Next
From:
chromatic
Date:
December 28, 2004 11:39
Subject:
Re: [perl #33173] shellwords.pl and tainting
Message ID:
1104262702.10768.1.camel@localhost
On Tue, 2004-12-28 at 22:29 +0300, Alexey Tourbin wrote:

> --- perl-5.9.2.23688/lib/Text/ParseWords/taint.t-	2004-12-28 21:21:26 +0300
> +++ perl-5.9.2.23688/lib/Text/ParseWords/taint.t	2004-12-28 21:39:56 +0300
> @@ -0,0 +1,23 @@
> +#!./perl -Tw
> +# [perl #33173] shellwords.pl and tainting
> +
> +BEGIN {
> +    chdir 't' if -d 't';
> +    @INC = '../lib';
> +    require Config;
> +    if ($Config::Config{extensions} !~ /\bList\/Util\b/) {
> +	print "1..0 # Skip: Scalar::Util was not built\n";
> +	exit 0;
> +    }
> +}
> +
> +use Text::ParseWords qw(shellwords old_shellwords);
> +use Scalar::Util qw(tainted);
> +
> +print "1..2\n";
> +
> +print "not " if grep { not tainted($_) } shellwords("$0$^X");
> +print "ok 1\n";
> +
> +print "not " if grep { not tainted($_) } old_shellwords("$0$^X");
> +print "ok 2\n";

This being a module, it's okay to use at least test.pl here, if not
Test::More.  It should have test comments either way.

-- c


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About