Subject: | [Patch] Fix a bug the last plaintext part might be chopped if called via scalarref |
This module doesn't call eof() when it deals with scalarref and
arrayref, which causes a bug that the last plaintext might be cut off
of the result. Here's a patch and a regression test to verify.
== lib/HTML/FillInForm.pm
==================================================================
--- lib/HTML/FillInForm.pm (revision 5460)
+++ lib/HTML/FillInForm.pm (local)
@@ -89,6 +89,8 @@
$self->parse($_);
}
}
+
+ $self->eof;
return delete $self->{output};
}
=== t/20_scalarref.t
==================================================================
--- t/20_scalarref.t (revision 5460)
+++ t/20_scalarref.t (local)
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+use Test::More;
+use HTML::FillInForm;
+
+# a few strings to test against
+my @contents = (
+ q{404},
+ q{404 Not Found},
+ q{Hello World},
+ q{<html><body>Hello World</body></html>},
+);
+
+# our number of tests in the number of elements in @contents
+plan tests => (scalar @contents);
+
+
+# run each string through H::FIF
+foreach my $content (@contents) {
+ my $output = HTML::FillInForm->new->fill(
+ scalarref => \$content,
+ fdat => {}
+ );
+
+ is($output, $content, q{output and content should be the same});
+}
+