Skip Menu |

This queue is for tickets about the WWW-Mechanize-PhantomJS CPAN distribution.

Report information
The Basics
Id: 131311
Status: new
Priority: 0/
Queue: WWW-Mechanize-PhantomJS

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.22
Fixed in: (no value)



Subject: make_link should probably not return the empty list
If make_link() does not find a URL (e.g. for <a> tags without a href), then the empty list is returned (see https://metacpan.org/source/CORION/WWW-Mechanize-PhantomJS-0.22/lib/WWW/Mechanize/PhantomJS.pm#L1168 ). However, this breaks https://metacpan.org/source/CORION/WWW-Mechanize-PhantomJS-0.22/lib/WWW/Mechanize/PhantomJS.pm#L1355 --- in this case the \%opt argument is moved to the first position! A possible test case which could be added to 50-mech-find-link.t: diff --git i/t/50-form2.html w/t/50-form2.html index 425bbe3..f461df7 100644 --- i/t/50-form2.html +++ w/t/50-form2.html @@ -4,6 +4,7 @@ <title>untitled</title> </head> <body> +<a name="nameonly">nameonly</a> <form id="snd0" method="POST" name="snd0" action="50-form2.html"> <input type="hidden" name="id" value=""> </form> diff --git i/t/50-mech-find-link.t w/t/50-mech-find-link.t index 95a4e9a..8b324bc 100644 --- i/t/50-mech-find-link.t +++ w/t/50-mech-find-link.t @@ -14,7 +14,7 @@ if (my $err = t::helper::default_unavailable) { plan skip_all => "Couldn't connect to PhantomJS: $@"; exit } else { - plan tests => 2*@instances; + plan tests => 3*@instances; }; #my $server = Test::HTTP::LocalServer->spawn( @@ -36,6 +36,7 @@ t::helper::run_across_instances(\@instances, $instance_port, \&new_mech, 2, sub my $link = $mech->find_link( text_regex => qr/\(1800\)/ ); # get all the links isa_ok $link, 'WWW::Mechanize::Link', "We found a link"; + is $link->text, '(1800)'; }); -wait; # gobble up our child process status \ No newline at end of file +wait; # gobble up our child process status A possible fix: diff --git i/lib/WWW/Mechanize/PhantomJS.pm w/lib/WWW/Mechanize/PhantomJS.pm index 0c08ef1..b37ac64 100644 --- i/lib/WWW/Mechanize/PhantomJS.pm +++ w/lib/WWW/Mechanize/PhantomJS.pm @@ -1165,7 +1165,7 @@ sub make_link { $res } else { - () + undef }; } @@ -1352,7 +1352,8 @@ sub find_link_dom { my $base = $self->base; require WWW::Mechanize; @res = grep { - WWW::Mechanize::_match_any_link_parms($self->make_link($_,$base),\%opts) + my $link = $self->make_link($_,$base); + $link ? WWW::Mechanize::_match_any_link_parms($link,\%opts) : () } @res; };