libwww-perl / WWW-Mechanize

Handy web browsing in a Perl object
https://metacpan.org/pod/WWW::Mechanize
Other
68 stars 53 forks source link

find_image* emits warning if $image->url is undef #269

Closed kenyapcomau closed 5 years ago

kenyapcomau commented 5 years ago

perl-WWW-Mechanize-1.75

If an img element doesn't have a src url this warning is emitted:

Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/vendor_perl/5.26.1/WWW/Mechanize.pm line 1217.

The line in this version is:

return if defined $p->{url_regex} && !($image->url =~ $p->{url_regex} );

It seems that the page in question uses some img elements with no src attribute but a data-image attribute which Javascript processes.

Therefore a guard condition like for alt attributes should be added.

oalders commented 5 years ago

Thanks for reporting this. We would accept a patch to fix it. :)

kenyapcomau commented 5 years ago

m.txt

oalders commented 5 years ago

Could we get a regression test for this as well?

simbabque commented 5 years ago

I've grabbed this.