Skip to content

Commit 6ebc560

Browse files
authored
Merge pull request #354 from libwww-perl/oalders/requote
Prefer q{} over ''
2 parents 6e1f465 + dc247f5 commit 6ebc560

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

lib/WWW/Mechanize.pm

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ sub form_with {
18621862
unless ( defined $spec{$_} ) { # case $attr => undef
18631863
qq{no $_};
18641864
}
1865-
elsif ( $spec{$_} eq '' ) { # case $attr=> ''
1865+
elsif ( $spec{$_} eq q{} ) { # case $attr=> ''
18661866
qq{empty $_};
18671867
}
18681868
else { # case $attr => $value
@@ -1871,7 +1871,7 @@ sub form_with {
18711871
} # case $attr => undef
18721872
sort keys %spec # sort keys to get deterministic messages
18731873
)
1874-
: ''
1874+
: q{}
18751875
)
18761876
. '. The first one was used.'
18771877
);
@@ -2244,7 +2244,7 @@ sub tick {
22442244
# Sometimes the HTML is malformed and there is no value for the check
22452245
# box, so we just return if the value passed is an empty string
22462246
# (and the form input is found)
2247-
if ($value eq '') {
2247+
if ($value eq q{}) {
22482248
$input->value($set ? $value : undef);
22492249
return;
22502250
}
@@ -2800,7 +2800,7 @@ sub save_content {
28002800
}
28012801

28022802
open( my $fh, '>', $filename ) or $self->die( "Unable to create $filename: $!" );
2803-
if ((my $binmode = delete($opts{binmode}) || '') || ($self->content_type() !~ m{^text/})) {
2803+
if ((my $binmode = delete($opts{binmode}) || q{}) || ($self->content_type() !~ m{^text/})) {
28042804
if (length($binmode) && (substr($binmode, 0, 1) eq ':')) {
28052805
binmode $fh, $binmode;
28062806
}
@@ -2828,7 +2828,7 @@ will be used as a file name.
28282828

28292829
sub _get_fh_default_stdout {
28302830
my $self = shift;
2831-
my $p = shift || '';
2831+
my $p = shift || q{};
28322832
if ( !$p ) {
28332833
return \*STDOUT;
28342834
} elsif ( !ref($p) ) {
@@ -2865,7 +2865,7 @@ sub dump_links {
28652865

28662866
for my $link ( $self->links ) {
28672867
my $url = $absolute ? $link->url_abs : $link->url;
2868-
$url = '' if not defined $url;
2868+
$url = q{} if not defined $url;
28692869
print {$fh} $url, "\n";
28702870
}
28712871
return;
@@ -2890,7 +2890,7 @@ sub dump_images {
28902890

28912891
for my $image ( $self->images ) {
28922892
my $url = $absolute ? $image->url_abs : $image->url;
2893-
$url = '' if not defined $url;
2893+
$url = q{} if not defined $url;
28942894
print {$fh} $url, "\n";
28952895
}
28962896
return;
@@ -3178,7 +3178,7 @@ sub _update_page {
31783178

31793179
$self->{status} = $res->code;
31803180
$self->{base} = $res->base;
3181-
$self->{ct} = $res->content_type || '';
3181+
$self->{ct} = $res->content_type || q{};
31823182

31833183
if ( $res->is_success ) {
31843184
$self->{uri} = $self->{redirected_uri};
@@ -3225,7 +3225,7 @@ sub _taintedness {
32253225
return $_taintbrush if tainted( $_taintbrush );
32263226

32273227
# Let's try again. Maybe somebody cleaned those.
3228-
$_taintbrush = substr(join('', grep { defined } @ARGV, %ENV), 0, 0);
3228+
$_taintbrush = substr(join(q{}, grep { defined } @ARGV, %ENV), 0, 0);
32293229
return $_taintbrush if tainted( $_taintbrush );
32303230

32313231
# If those don't work, go try to open some file from some unsafe
@@ -3485,7 +3485,7 @@ sub _link_from_token {
34853485
my $name;
34863486
if ( $tag eq 'a' ) {
34873487
$text = $parser->get_trimmed_text("/$tag");
3488-
$text = '' unless defined $text;
3488+
$text = q{} unless defined $text;
34893489

34903490
my $onClick = $attrs->{onclick};
34913491
if ( $onClick && ($onClick =~ /^window\.open\(\s*'([^']+)'/) ) {

t/form_with_fields.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
110110
like(
111111
exception {
112112
$mech->submit_form(
113-
with_fields => { 'xx' => '' },
113+
with_fields => { 'xx' => q{} },
114114
);
115115
},
116116
qr/There is no form with the requested fields/,
@@ -123,7 +123,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
123123
like(
124124
exception {
125125
$mech->submit_form(
126-
with_fields => { '1a' => '' },
126+
with_fields => { '1a' => q{} },
127127
form_number => 2,
128128
);
129129
},
@@ -164,7 +164,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
164164
is(
165165
exception {
166166
$mech->submit_form(
167-
with_fields => { 'x' => '' },
167+
with_fields => { 'x' => q{} },
168168
form_name => '3rd_form_ambiguous',
169169
);
170170
},
@@ -178,7 +178,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
178178
is(
179179
exception {
180180
$mech->submit_form(
181-
with_fields => { '1b' => '', 'opt[2]' => '' },
181+
with_fields => { '1b' => q{}, 'opt[2]' => q{} },
182182
);
183183
},
184184
undef,

t/form_with_fields_passthrough_params.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
7070
like(
7171
exception {
7272
$mech->submit_form(
73-
with_fields => { 'xx' => '' },
73+
with_fields => { 'xx' => q{} },
7474
);
7575
},
7676
qr/There is no form with the requested fields/,
@@ -83,7 +83,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
8383
like(
8484
exception {
8585
$mech->submit_form(
86-
with_fields => { '1a' => '' },
86+
with_fields => { '1a' => q{} },
8787
form_number => 2,
8888
);
8989
},
@@ -124,7 +124,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
124124
is(
125125
exception {
126126
$mech->submit_form(
127-
with_fields => { 'x' => '' },
127+
with_fields => { 'x' => q{} },
128128
form_name => '3rd_form_ambiguous',
129129
);
130130
},
@@ -138,7 +138,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
138138
is(
139139
exception {
140140
$mech->submit_form(
141-
with_fields => { '1b' => '', 'opt[2]' => '' },
141+
with_fields => { '1b' => q{}, 'opt[2]' => q{} },
142142
);
143143
},
144144
undef,

t/image-parse.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ $mech->get( $uri );
8282
ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
8383

8484
eval { @images = $mech->find_all_images(); };
85-
is($@,'','survived eval');
85+
is($@,q{},'survived eval');
8686
is( scalar @images, 2, 'Exactly two images' );
8787

8888
my $css_first = $images[0];

t/local/LocalServer.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ sub spawn {
9999
close $fh;
100100
push @{$self->{delete}},$logfile;
101101
$self->{logfile} = $logfile;
102-
my $web_page = delete $args{file} || "";
102+
my $web_page = delete $args{file} || q{};
103103

104104
my $server_file = path('t/local/log-server')->absolute;
105105
my @opts;

t/local/form.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ is( $mech->current_form, $form_number_1,
8989

9090
my $form_number_2 = $mech->form_number(2);
9191
$form_with =
92-
$mech->form_with( class => 'test', foo => '', bar => undef, { n => 2 } );
92+
$mech->form_with( class => 'test', foo => q{}, bar => undef, { n => 2 } );
9393
is( $form_with, $form_number_2, 'Can select nth form with ambiguous criteria' );
9494

9595
is( scalar @warnings, 0, 'no warnings so far' );
9696
$mech->quiet(0);
97-
$form_with = $mech->form_with( class => 'test', foo => '', bar => undef );
97+
$form_with = $mech->form_with( class => 'test', foo => q{}, bar => undef );
9898
is( $form_with, $form_number_1,
9999
'form_with - can select form with ambiguous criteria' );
100100
is( scalar @warnings, 1, 'form_with - got one warning' );

t/local/select_multiple.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ eval {
4949
}
5050
);
5151
};
52-
is( $@, '', 'submit_form, second value' );
52+
is( $@, q{}, 'submit_form, second value' );
5353
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
5454

5555
eval {
@@ -58,7 +58,7 @@ eval {
5858
chanId => 119,
5959
);
6060
};
61-
is( $@, '', 'set_fields, second value' );
61+
is( $@, q{}, 'set_fields, second value' );
6262
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
6363

6464

@@ -70,7 +70,7 @@ eval {
7070
}
7171
);
7272
};
73-
is( $@, '', 'submit_form, second value as array' );
73+
is( $@, q{}, 'submit_form, second value as array' );
7474
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
7575

7676

@@ -81,7 +81,7 @@ eval {
8181
);
8282
$mech->submit;
8383
};
84-
is( $@, '', 'field, second value' );
84+
is( $@, q{}, 'field, second value' );
8585
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
8686

8787

@@ -92,7 +92,7 @@ eval {
9292
);
9393
$mech->submit;
9494
};
95-
is( $@, '', 'field, second value as array' );
95+
is( $@, q{}, 'field, second value as array' );
9696
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
9797

9898

@@ -104,7 +104,7 @@ eval {
104104
}
105105
);
106106
};
107-
is( $@, '', 'submit_form, first value' );
107+
is( $@, q{}, 'submit_form, first value' );
108108
like( $mech->uri, qr/chanId=130/, '... and the first value was set');
109109

110110

t/local/submit.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ is( $mech->uri, $server->url, 'Got the correct page' );
2525
ok( $response->is_success, 'Got local page' ) or die 'cannot even fetch local page';
2626
ok( $mech->is_html, 'is HTML' );
2727

28-
is( $mech->value('upload'), '', 'Hopefully no upload happens');
28+
is( $mech->value('upload'), q{}, 'Hopefully no upload happens');
2929

3030
$mech->field(query => 'foo'); # Filled the 'q' field
3131

@@ -35,7 +35,7 @@ ok( $response->is_success, 'Can click "submit" ("submit" button)');
3535

3636
like($mech->content, qr/\bfoo\b/i, 'Found "Foo"');
3737

38-
is( $mech->value('upload'), '', 'No upload happens' );
38+
is( $mech->value('upload'), q{}, 'No upload happens' );
3939

4040
SKIP: {
4141
skip 'Test::Memory::Cycle not installed', 1 unless $canTMC;

t/save_content.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ sub slurp {
5353
my $name = shift;
5454

5555
open( my $fh, '<', $name ) or die "Can't open $name: $!\n";
56-
return join '', <$fh>;
56+
return join q{}, <$fh>;
5757
}

t/tick.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $mech->tick('foo','hello');
2121
$mech->tick('foo','bye');
2222
$mech->untick('foo','hello');
2323

24-
$mech->tick('no_value', '');
24+
$mech->tick('no_value', q{});
2525

2626
my $form = $mech->form_number(1);
2727
isa_ok( $form, 'HTML::Form' );

0 commit comments

Comments
 (0)