| 1 |
#!perl -T |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use Test::More tests => 2; |
| 7 |
|
| 8 |
use Scalar::Util qw(tainted); |
| 9 |
use Locale::Maketext; |
| 10 |
|
| 11 |
my @ENV_values = map { !/^PERL/ && defined($ENV{$_}) && !ref($ENV{$_}) && $ENV{$_} ? $ENV{$_} : () } sort keys %ENV; |
| 12 |
die "No %ENV vars to test?" if !@ENV_values; |
| 13 |
|
| 14 |
my ($tainted_value)= @ENV_values; |
| 15 |
$tainted_value =~ s/([\[\]])/~$1/g; |
| 16 |
|
| 17 |
# If ${^TAINT} is not set despite -T, this perl doesn't have taint support |
| 18 |
ok(!${^TAINT} || tainted($tainted_value), "\$tainted_value is tainted") |
| 19 |
or die("Could not find tainted value to use for testing (maybe fix the test?)"); |
| 20 |
|
| 21 |
my $result = Locale::Maketext::_compile("hello [_1]", $tainted_value); |
| 22 |
|
| 23 |
pass("_compile does not hang on tainted values"); |
| 24 |
|