[libhtml-scrubber-perl] 01/28: check for definedness before calling ->parse
Florian Schlichting
fsfs at moszumanska.debian.org
Sat Nov 11 13:46:08 UTC 2017
This is an automated email from the git hooks/post-receive script.
fsfs pushed a commit to annotated tag release/0.12-TRIAL
in repository libhtml-scrubber-perl.
commit 3fb1b6bef5ac0fd5c1d7902849bc417716ad0a57
Author: Lee Johnson <lee at givengain.ch>
Date: Thu Jul 17 15:19:53 2014 +0200
check for definedness before calling ->parse
on $_[1] in sub scrub, otherwise we get:
Use of uninitialized value in subroutine entry
which isn't helpful and fills up logs. really scrub shouldn't be
called sans a second argument, but probably a good idea to do the
right thing here too
---
lib/HTML/Scrubber.pm | 2 +-
t/09_no_scrub_warnings.t | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/lib/HTML/Scrubber.pm b/lib/HTML/Scrubber.pm
index 5dfcc97..61320d5 100644
--- a/lib/HTML/Scrubber.pm
+++ b/lib/HTML/Scrubber.pm
@@ -330,7 +330,7 @@ sub scrub {
$_[0]->_optimize();# if $_[0]->{_optimize};
- $_[0]->{_p}->parse($_[1]);
+ $_[0]->{_p}->parse($_[1]) if defined($_[1]);
$_[0]->{_p}->eof();
return delete $_[0]->{_r} unless exists $_[0]->{_out};
diff --git a/t/09_no_scrub_warnings.t b/t/09_no_scrub_warnings.t
new file mode 100644
index 0000000..fc9135d
--- /dev/null
+++ b/t/09_no_scrub_warnings.t
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+use Test::More;
+
+use_ok('HTML::Scrubber');
+use HTML::Scrubber;
+
+my $scrubber = HTML::Scrubber->new;
+
+# really one of the Test:: warnings would be better here
+# but lets keep this simple
+local $SIG{__WARN__} = sub {
+ fail( "warning raised by scrub: @_" );
+};
+
+ok( ! $scrubber->scrub );
+ok( ! $scrubber->scrub('') );
+ok( ! $scrubber->scrub('<html></html>') );
+
+done_testing;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libhtml-scrubber-perl.git
More information about the Pkg-perl-cvs-commits
mailing list