blob: 07626c2123054b0ea20411223f156b5912441468 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package re;
=head1 NAME
re - Perl pragma to alter regular expression behaviour
=head1 SYNOPSIS
($x) = ($^X =~ /^(.*)$/s); # $x is not tainted here
use re "taint";
($x) = ($^X =~ /^(.*)$/s); # $x _is_ tainted here
=head1 DESCRIPTION
When C<use re 'taint'> is in effect, and a tainted string is the target
of a regex, the regex memories (or values returned by the m// operator
in list context) are tainted.
This feature is useful when regex operations on tainted data aren't
meant to extract safe substrings, but to perform other transformations.
See L<perlmodlib/Pragmatic Modules>.
=cut
my %bitmask = (
taint => 0x00001000
);
sub bits {
my $bits = 0;
unless(@_) {
require Carp;
Carp::carp("Useless use of \"re\" pragma");
}
foreach my $s (@_){ $bits |= $bitmask{$s} || 0; };
$bits;
}
sub import {
shift;
$^H |= bits(@_);
}
sub unimport {
shift;
$^H &= ~ bits(@_);
}
1;
|