Bug#690571: Tainted variable causes wrong smart matching in given/when constructs

Christoph Nodes bug-debian at bfw-online.de
Mon Oct 15 15:52:43 UTC 2012


Package: perl
Version: 5.14.2-14

The attached perl program behaves differently in taint mode compared to 
non taint mode:

#!/usr/bin/perl -w
use strict;
use feature qw (switch);

my $tainted_var = $ENV{X};
given ($tainted_var)
{ when ([0, 1])
   { print "smart match\n";
   }
}

If X is set to 0 there is no difference:

$ X=0 perl taintbug
smart match
$ X=0 perl -T taintbug
smart match
$

If X is set to 1 the "when" block is not entered in taint mode and nothing 
is printed

$ X=1 perl -T taintbug
$

whereas in non taint mode it behaves like expected:

$ X=1 perl taintbug
smart match
$

I consider this a bug.


Best regards

-- 
Christoph Nodes
-------------- next part --------------
#!/usr/bin/perl -w
use strict;
use feature qw (switch);

my $tainted_var = 1;
given ($tainted_var)
{ when ([0, 1])
  { print "smart match\n";
  }
}


More information about the Perl-maintainers mailing list