Skip to content

Commit fe65d9b

Browse files
petdanceoalders
authored andcommitted
Remove tainting behavior. Remove Scalar::Util as a prereq.
1 parent 432ebf3 commit fe65d9b

File tree

4 files changed

+3
-64
lines changed

4 files changed

+3
-64
lines changed

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Revision history for WWW::Mechanize
22

33
{{$NEXT}}
4+
[ENHANCEMENTS]
5+
- WWW::Mechanize no longer taints the responses it receives. This also
6+
removes Test::Taint as a prerequisite.
47

58
2.19 2024-09-16 15:25:45Z
69
[DOCUMENTATION]

dist.ini

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ dir = script
2525
[Prereqs / RuntimeRequires]
2626
perl = 5.008
2727
HTML::Form = 6.08
28-
Scalar::Util = 1.14
2928

3029
[Prereqs / TestRequires]
3130
HTTP::Daemon = 6.12

lib/WWW/Mechanize.pm

-40
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ use Tie::RefHash ();
140140
use HTTP::Request 1.30 ();
141141
use HTML::Form 1.00 ();
142142
use HTML::TokeParser ();
143-
use Scalar::Util qw( tainted );
144143

145144
use parent 'LWP::UserAgent';
146145

@@ -3364,8 +3363,6 @@ sub _update_page {
33643363
my $content = $res->decoded_content();
33653364
$content = $res->content if ( not defined $content );
33663365

3367-
$content .= _taintedness();
3368-
33693366
if ( $self->is_html ) {
33703367
$self->update_html($content);
33713368
}
@@ -3376,43 +3373,6 @@ sub _update_page {
33763373
return $res;
33773374
} # _update_page
33783375

3379-
our $_taintbrush;
3380-
3381-
# This is lifted wholesale from Test::Taint
3382-
sub _taintedness {
3383-
return $_taintbrush if defined $_taintbrush;
3384-
3385-
# Somehow we need to get some taintedness into our $_taintbrush.
3386-
# Let's try the easy way first. Either of these should be
3387-
# tainted, unless somebody has untainted them, so this
3388-
# will almost always work on the first try.
3389-
# (Unless, of course, taint checking has been turned off!)
3390-
$_taintbrush = substr( "$0$^X", 0, 0 );
3391-
return $_taintbrush if tainted($_taintbrush);
3392-
3393-
# Let's try again. Maybe somebody cleaned those.
3394-
$_taintbrush = substr( join( q{}, grep { defined } @ARGV, %ENV ), 0, 0 );
3395-
return $_taintbrush if tainted($_taintbrush);
3396-
3397-
# If those don't work, go try to open some file from some unsafe
3398-
# source and get data from them. That data is tainted.
3399-
# (Yes, even reading from /dev/null works!)
3400-
for my $filename ( qw(/dev/null / . ..), values %INC, $0, $^X ) {
3401-
if ( open my $fh, '<', $filename ) {
3402-
my $data;
3403-
if ( defined sysread $fh, $data, 1 ) {
3404-
$_taintbrush = substr( $data, 0, 0 );
3405-
last if tainted($_taintbrush);
3406-
}
3407-
}
3408-
}
3409-
3410-
# Sanity check
3411-
die("Our taintbrush should have zero length!") if length $_taintbrush;
3412-
3413-
return $_taintbrush;
3414-
}
3415-
34163376
=head2 $mech->_modify_request( $req )
34173377
34183378
Modifies a L<HTTP::Request> before the request is sent out,

t/taint.t

-23
This file was deleted.

0 commit comments

Comments
 (0)