Hello community,
here is the log from the commit of package perl-HTML-FillInForm
checked in at Mon Oct 8 12:27:07 CEST 2007.
--------
--- perl-HTML-FillInForm/perl-HTML-FillInForm.changes 2006-01-25 21:39:44.000000000 +0100
+++ /mounts/work_src_done/STABLE/perl-HTML-FillInForm/perl-HTML-FillInForm.changes 2007-10-08 09:47:10.000000000 +0200
@@ -1,0 +2,12 @@
+Mon Oct 8 09:23:04 CEST 2007 - anicka@suse.cz
+
+- update to 2.00
+ * Allow passing an arrayref of hashrefs through fdat
+ * Several new shortcuts
+ * Add support for ID attribute on form tags
+ * Added 'disable_fields' method
+ * Support IE down-level revealed HTML comments
+ * hash is not reset before each() is called
+ * bugfixes
+
+-------------------------------------------------------------------
Old:
----
HTML-FillInForm-1.06.tar.bz2
New:
----
HTML-FillInForm-2.00.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-HTML-FillInForm.spec ++++++
--- /var/tmp/diff_new_pack.tx7962/_old 2007-10-08 12:27:03.000000000 +0200
+++ /var/tmp/diff_new_pack.tx7962/_new 2007-10-08 12:27:03.000000000 +0200
@@ -1,25 +1,25 @@
#
-# spec file for package perl-HTML-FillInForm (Version 1.06)
+# spec file for package perl-HTML-FillInForm (Version 2.00)
#
-# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
-# Please submit bugfixes or comments via http://bugs.opensuse.org
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
Name: perl-HTML-FillInForm
BuildRequires: perl-HTML-Parser
-Version: 1.06
+Version: 2.00
Release: 1
Requires: perl-HTML-Parser >= 3.26
Requires: perl = %{perl_version}
-Autoreqprov: on
+AutoReqProv: on
Group: Development/Libraries/Perl
License: Artistic License
-URL: http://cpan.org/modules/by-module/HTML/
+Url: http://cpan.org/modules/by-module/HTML/
Summary: Perl module HTML::FillInForm
Source: HTML-FillInForm-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -57,8 +57,16 @@
%{perl_vendorlib}/HTML
%{perl_vendorarch}/auto/HTML
/var/adm/perl-modules/%{name}
-
-%changelog -n perl-HTML-FillInForm
+%changelog
+* Mon Oct 08 2007 - anicka@suse.cz
+- update to 2.00
+ * Allow passing an arrayref of hashrefs through fdat
+ * Several new shortcuts
+ * Add support for ID attribute on form tags
+ * Added 'disable_fields' method
+ * Support IE down-level revealed HTML comments
+ * hash is not reset before each() is called
+ * bugfixes
* Wed Jan 25 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
* Tue Jan 03 2006 - anicka@suse.cz
++++++ HTML-FillInForm-1.06.tar.bz2 -> HTML-FillInForm-2.00.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/Changes new/HTML-FillInForm-2.00/Changes
--- old/HTML-FillInForm-1.06/Changes 2005-10-13 22:48:49.000000000 +0200
+++ new/HTML-FillInForm-2.00/Changes 2007-09-12 02:16:07.000000000 +0200
@@ -1,3 +1,46 @@
+2.0 - September 11th, 2007
+
+Allow passing an arrayref of hashrefs through fdat (Mark Stosberg, Michael Graham)
+
+Several new shortcuts: (Mark Stosberg)
+ Allow calling fill() as a class method as a shortcut.
+ Allow \$html as shortcut for scalarref => \$html
+ Allow \@html as shortcut for arrayref => \@html
+ Allow \*html as shortcut for file => \*html
+ Allow 'html' as shortcut for file => 'html'
+ Allow $q as shortcut for fobject => $q
+ Allow \%fdat as shortcut for fdat => \%fdat
+
+ In summary, instead of this:
+
+ my $fif = HTML::FillInForm->new;
+ $fif->fill( scalarref => \$html, fdat => \%data );
+
+ You can simply write:
+
+ HTML::FillInForm->fill( \$html, \%data );
+
+Fixed disable_fields bug (Boris Zentner)
+
+Add support for ID attribute on form tags (name attribute is
+deprecated in xhtml) [rt.cpan.org #27376] (Anthony Ettinger)
+
+1.07 - August 2nd, 2007
+
+Added 'disable_fields' method [rt.cpan.org #6342] (Trevor Schellhorn)
+
+Support IE down-level revealed HTML comments [rt.cpan.org #19468] (Michael Peters)
+
+hash is not reset before each() is called [rt.cpan.org #24980] (Simon P. Ditner)
+
+Fix a bug the last plaintext part might be chopped if called via
+scalarref [rt.cpan.org #21750] (Tatsuhiko Miyagawa)
+
+Fix bug when passing 0 in array ref to textfields, also see
+[rt.cpan.org #22195] (Paul Miller)
+
+No longer generate warning if empty array as the value for a select attribute is passed (Dave Rolsky)
+
1.06 - October 13th, 2005
Distinguish between selects with and without the multiple attribute set (Alexander Hartmaier)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/lib/HTML/FillInForm.pm new/HTML-FillInForm-2.00/lib/HTML/FillInForm.pm
--- old/HTML-FillInForm-1.06/lib/HTML/FillInForm.pm 2005-10-13 22:49:09.000000000 +0200
+++ new/HTML-FillInForm-2.00/lib/HTML/FillInForm.pm 2007-09-12 02:20:01.000000000 +0200
@@ -12,7 +12,7 @@
require 5.005;
use vars qw($VERSION @ISA);
-$VERSION = '1.06';
+$VERSION = '2.00';
@ISA = qw(HTML::Parser);
@@ -26,21 +26,112 @@
}
# a few shortcuts to fill()
-sub fill_file { my $self = shift; return $self->fill('file',@_); }
-sub fill_arrayref { my $self = shift; return $self->fill('arrayref',@_); }
+sub fill_file { my $self = shift; return $self->fill('file' ,@_); }
+sub fill_arrayref { my $self = shift; return $self->fill('arrayref' ,@_); }
sub fill_scalarref { my $self = shift; return $self->fill('scalarref',@_); }
+# track the keys we support. Useful for file-name detection.
+sub _known_keys {
+ return {
+ scalarref => 1,
+ arrayref => 1,
+ fdat => 1,
+ fobject => 1,
+ file => 1,
+ target => 1,
+ fill_password => 1,
+ ignore_fields => 1,
+ disable_fields => 1,
+ }
+}
+
sub fill {
- my ($self, %option) = @_;
+ my $self = shift;
+
+ # If we are called as a class method, go ahead and call new().
+ $self = $self->new if (not ref $self);
+
+ my %option;
+
+ # If the first arg is a scalarref, translate that to scalarref => $first_arg
+ if (ref $_[0] eq 'SCALAR') {
+ $option{scalarref} = shift;
+ }
+ elsif (ref $_[0] eq 'ARRAY') {
+ $option{arrayref} = shift;
+ }
+ elsif (ref $_[0] eq 'GLOB') {
+ $option{file} = shift;
+ }
+ elsif (ref $_[0]) {
+ croak "data source is not a reference type we understand";
+ }
+ # Last chance, if the first arg isn't one of the known keys, we
+ # assume it is a file name.
+ elsif (not _known_keys()->{$_[0]} ) {
+ $option{file} = shift;
+ }
+ else {
+ # Should be a known key. Nothing to do.
+ }
+
+
+ # Now, check to see if the next arg is also a reference.
+ my $data;
+ if (ref $_[0]) {
+ $data = shift;
+ $data = [$data] unless ref $data eq 'ARRAY';
+
+ for my $source (@$data) {
+ if (ref $source eq 'HASH') {
+ push @{ $option{fdat} }, $source;
+ }
+ elsif (ref $source) {
+ if ($source->can('param')) {
+ push @{ $option{fobject} }, $source;
+ }
+ else {
+ croak "data source $source does not supply a param method";
+ }
+ }
+ elsif (defined $source) {
+ croak "data source $source is not a hash or object reference";
+ }
+ }
+
+ }
+
+
+ # load in the rest of the options
+ %option = (%option, @_);
+
+
+ # As suggested in the docs, merge multiple fdats into one.
+ if (ref $option{fdat} eq 'ARRAY') {
+ my %merged;
+ for my $hash (@{ $option{fdat} }) {
+ for my $key (keys %$hash) {
+ $merged{$key} = $hash->{$key};
+ }
+ }
+ $option{'fdat'} = \%merged;
+ }
+
my %ignore_fields;
%ignore_fields = map { $_ => 1 } ( ref $option{'ignore_fields'} eq 'ARRAY' )
? @{ $option{ignore_fields} } : $option{ignore_fields} if exists( $option{ignore_fields} );
$self->{ignore_fields} = \%ignore_fields;
+ my %disable_fields;
+ %disable_fields = map { $_ => 1 } ( ref $option{'disable_fields'} eq 'ARRAY' )
+ ? @{ $option{disable_fields} } : $option{disable_fields} if exists( $option{disable_fields} );
+ $self->{disable_fields} = \%disable_fields;
+
if (my $fdat = $option{fdat}){
# Copy the structure to prevent side-effects.
my %copy;
+ keys %$fdat; # reset fdat if each or Dumper was called on fdat
while(my($key, $val) = each %$fdat) {
next if exists $ignore_fields{$key};
$copy{ $key } = ref $val eq 'ARRAY' ? [ @$val ] : $val;
@@ -89,6 +180,8 @@
$self->parse($_);
}
}
+
+ $self->eof;
return delete $self->{output};
}
@@ -99,8 +192,8 @@
# set the current form
if ($tagname eq 'form') {
$self->{object_param_cache} = {};
- if (exists $attr->{'name'}) {
- $self->{'current_form'} = $attr->{'name'};
+ if (exists $attr->{'name'} || exists $attr->{'id'}) {
+ $self->{'current_form'} = $attr->{'name'} || $attr->{'id'};
} else {
# in case of previous one without </FORM>
delete $self->{'current_form'};
@@ -120,6 +213,13 @@
$self->{output} .= '>';
delete $self->{option_no_value};
}
+
+ # Check if we need to disable this field
+ $attr->{disable} = 1
+ if exists $attr->{'name'} and
+ exists $self->{disable_fields}{ $attr->{'name'} } and
+ $self->{disable_fields}{ $attr->{'name'} } and
+ not ( exists $attr->{disable} and $attr->{disable} );
if ($tagname eq 'input'){
my $value = exists $attr->{'name'} ? $self->_get_param($attr->{'name'}) : undef;
# force hidden fields to have a value
@@ -129,13 +229,22 @@
# check for input type, noting that default type is text
if (!exists $attr->{'type'} ||
$attr->{'type'} =~ /^(text|textfield|hidden|)$/i){
- $value = (shift @$value || '') if ref($value) eq 'ARRAY';
+ if ( ref($value) eq 'ARRAY' ) {
+ $value = shift @$value;
+ $value = '' unless defined $value;
+ }
$attr->{'value'} = $value;
} elsif (lc $attr->{'type'} eq 'password' && $self->{fill_password}) {
- $value = (shift @$value || '') if ref($value) eq 'ARRAY';
+ if ( ref($value) eq 'ARRAY' ) {
+ $value = shift @$value;
+ $value = '' unless defined $value;
+ }
$attr->{'value'} = $value;
} elsif (lc $attr->{'type'} eq 'radio'){
- $value = ($value->[0] || '') if ref($value) eq 'ARRAY';
+ if ( ref($value) eq 'ARRAY' ) {
+ $value = $value->[0];
+ $value = '' unless defined $value;
+ }
# value for radio boxes default to 'on', works with netscape
$attr->{'value'} = 'on' unless exists $attr->{'value'};
if ($attr->{'value'} eq $value){
@@ -168,10 +277,10 @@
$self->{output} .= ">";
} elsif ($tagname eq 'option'){
my $value = $self->_get_param($self->{selectName});
+ $value = [ $value ] unless ( ref($value) eq 'ARRAY' );
- if (defined($value)){
+ if ( defined $value->[0] ){
$value = $self->escapeHTMLStringOrList($value);
- $value = [ $value ] unless ( ref($value) eq 'ARRAY' );
delete $attr->{selected} if exists $attr->{selected};
if(defined($attr->{'value'})){
@@ -179,7 +288,7 @@
if ($self->{selectMultiple}){
# check if the option tag belongs to a multiple option select
- foreach my $v ( @$value ) {
+ foreach my $v ( grep { defined } @$value ) {
if ( $attr->{'value'} eq $v ){
$attr->{selected} = 'selected';
}
@@ -322,8 +431,25 @@
}
sub comment {
- my ( $self, $text ) = @_;
- $self->{output} .= '<!--' . $text . '-->';
+ my ( $self, $text ) = @_;
+ # if it begins with '[if ' and doesn't end with '{output} .= '';
+ } else {
+ $self->{output} .= '<!--' . $text . '-->';
+ }
}
sub process {
@@ -346,110 +472,121 @@
=head1 DESCRIPTION
-This module automatically inserts data from a previous HTML form into the HTML input, textarea,
-radio buttons, checkboxes and select tags.
-It is a subclass of LHTML::Parser and uses it to parse the HTML and insert the values into the form tags.
-
-One useful application is after a user submits an HTML form without filling out a
-required field. HTML::FillInForm can be used to redisplay the HTML form
-with all the form elements containing the submitted info.
+This module fills in an HTML form with data from a Perl data structure, allowing you
+to keep the HTML and Perl separate.
+
+Here are two common use cases:
+
+1. A user submits an HTML form without filling out a required field. You want
+to redisplay the form with all the previous data in it, to make it easy for the
+user to see and correct the error.
+
+2. You have just retrieved a record from a database and need to display it in
+an HTML form.
=head1 SYNOPSIS
-This examples fills data into a HTML form stored in C<$htmlForm> from CGI parameters that are stored
-in C<$q>. For example, it will set the value of any "name" textfield to "John Smith".
+Fill HTML form with data.
- my $q = new CGI;
+ $output = HTML::FillInForm->fill( \$html, $q );
+ $output = HTML::FillInForm->fill( \@html, [$q1,$q2] );
+ $output = HTML::FillInForm->fill( \*HTML, \%data );
+ $output = HTML::FillInForm->fill( 't.html', [\%data1,%data2] );
- $q->param("name","John Smith");
+The HTML can be provided as a scalarref, arrayref, filehandle or file. The data can come from one or more
+hashrefs, or objects which support a param() method, like CGI.pm, LApache::Request|Apache::Request, etc.
- my $fif = new HTML::FillInForm;
- my $output = $fif->fill(scalarref => \$html,
- fobject => $q);
+=head1 fill
-Note CGI.pm is B<not> required - see using fdat below. Also you can use a CGI.pm-like object such as Apache::Request.
+The basic syntax is seen above the Synopsis. There are a few additional options.
-=head1 METHODS
+=head2 Options
-=over 4
+=head3 target => 'form1'
-=item new
+Suppose you have multiple forms in a html file and only want to fill in one.
-Call C to create a new FillInForm object:
+ $output = HTML::FillInForm->fill(\$html, $q, target => 'form1');
- $fif = new HTML::FillInForm;
+This will fill in only the form inside
-=item fill
+ <FORM name="form1"> ... </FORM>
-To fill in a HTML form contained in a scalar C<$html>:
+=head3 fill_password => 0
- $output = $fif->fill(scalarref => \$html,
- fobject => $q);
+Passwords are filled in by default. To disable:
-Returns filled in HTML form contained in C<$html> with data from C<$q>.
-C<$q> is required to have a C method that works like
-CGI's C.
+ fill_password => 0
- $output = $fif->fill(scalarref => \$html,
- fobject => [$q1, $q2]);
+=head3 ignore_fields => []
-As of 1.04 the object passed does not need to return all its keys with
-a empty param() call.
+To disable the filling of some fields:
-Note that you can pass multiple objects as an array reference.
+ ignore_fields => ['prev','next']
- $output = $fif->fill(scalarref => \$html,
- fdat => \%fdat);
+=head3 disable_fields => []
-Returns filled in HTML form contained in C<$html> with data from C<%fdat>.
-To pass multiple values using C<%fdat> use an array reference.
+To disable fields from being edited:
-Alternately you can use
+ disable_fields => [ 'uid', 'gid' ]
- $output = $fif->fill(arrayref => \@array_of_lines,
- fobject => $q);
+=head2 File Upload fields
-and
+File upload fields cannot be supported directly. Workarounds include asking the
+user to re-attach any file uploads or fancy server-side storage and
+referencing. You are on your own.
- $output = $fif->fill(file => 'form.tmpl',
- fobject => $q);
+=head2 Clearing Fields
-Suppose you have multiple forms in a html and among them there is only
-one form you want to fill in, specify target.
+Fields are cleared if you set their value to an empty string or empty arrayref but not undef:
- $output = $fif->fill(scalarref => \$html,
- fobject => $q,
- target => 'form1');
+ # this will leave the form element foo untouched
+ HTML::FillInForm->fill(\$html, { foo => undef });
-This will fill in only the form inside
+ # this will set clear the form element foo
+ HTML::FillInForm->fill(\$html, { foo => "" });
- <FORM name="form1"> ... </FORM>
+It has been suggested to add a option to change the behavior so that undef
+values will clear the form elements. Patches welcome.
-Note that this method fills in password fields by default. To disable, pass
+=head1 Old syntax
- fill_password => 0
+You probably need to read no further. The remaining docs concern the
+1.x era syntax, which is still supported.
+
+=head2 new
-To disable the filling of some fields, use the C option:
+Call C to create a new FillInForm object:
- $output = $fif->fill(scalarref => \$html,
- fobject => $q,
- ignore_fields => ['prev','next']);
+ $fif = HTML::FillInForm->new;
+ $fif->fill(...);
-Note that this module does not clear fields if you set the value to undef.
-It will clear fields if you set the value to an empty array or an empty string. For example:
+In theory, there is a slight performance benefit to calling C before C if you make multiple
+calls to C before you destroy the object. Benchmark before optimizing.
- # this will leave the form element foo untouched
- $output = $fif->fill(scalarref => \$html,
- fdat => { foo => undef });
+=head2 fill ( old syntax )
- # this will set clear the form element foo
- $output = $fif->fill(scalarref => \$html,
- fdat => { foo => "" });
+Instead of having your HTML and data types auto-detected, you can declare them explicitly in your
+call to C:
+
+HTML source options:
+
+ arrayref => @html
+ scalarref => $html
+ file => \*HTML
+ file => 't.html'
+
+Fill Data options:
+
+ fobject => $data_obj # with param() method
+ fdat => \%data
-It has been suggested to add a option to the new constructer to change the behavior
-so that undef values will clear the form elements. Patches welcome.
+Additional methods are also available:
-=back
+ fill_file(\*HTML,...);
+ fill_file('t.html',...);
+ fill_arrayref(\@html,...);
+ fill_scalarref(\$html,...);
=head1 CALLING FROM OTHER MODULES
@@ -475,7 +612,7 @@
=head1 VERSION
-This documentation describes HTML::FillInForm module version 1.06.
+This documentation describes HTML::FillInForm module version 2.00
=head1 SECURITY
@@ -520,32 +657,28 @@
=head1 SEE ALSO
-LHTML::Parser, LData::FormValidator, LHTML::Template, LApache::PageKit
+LHTML::Parser|HTML::Parser,
+LData::FormValidator|Data::FormValidato,
+LHTML::Template|HTML::Template,
+LApache::PageKit|Apache::PageKit
=head1 CREDITS
Fixes, Bug Reports, Docs have been generously provided by:
- Tatsuhiko Miyagawa
- Boris Zentner
- Dave Rolsky
- Patrick Michael Kane
- Ade Olonoh
- Tom Lancaster
- Martin H Sluka
- Mark Stosberg
- Jonathan Swartz
- Trevor Schellhorn
- Jim Miner
- Paul Lindner
- Maurice Aubrey
- Andrew Creer
- Joseph Yanni
- Philip Mak
- Jost Krieger
- Gabriel Burka
- Bill Moseley
- James Tolley
- Dan Kubb
+ Tatsuhiko Miyagawa Joseph Yanni
+ Boris Zentner Philip Mak
+ Dave Rolsky Jost Krieger
+ Patrick Michael Kane Gabriel Burka
+ Ade Olonoh Bill Moseley
+ Tom Lancaster James Tolley
+ Martin H Sluka Dan Kubb
+ Mark Stosberg Alexander Hartmaier
+ Jonathan Swartz Paul Miller
+ Trevor Schellhorn Anthony Ettinger
+ Jim Miner Simon P. Ditner
+ Paul Lindner Michael Peters
+ Maurice Aubrey Trevor Schellhorn
+ Andrew Creer
Thanks!
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/MANIFEST new/HTML-FillInForm-2.00/MANIFEST
--- old/HTML-FillInForm-1.06/MANIFEST 2004-12-20 05:01:00.000000000 +0100
+++ new/HTML-FillInForm-2.00/MANIFEST 2007-08-02 20:51:19.000000000 +0200
@@ -23,5 +23,8 @@
t/17_xhtml.t
t/18_ignore_fdat.t
t/19_extra.t
+t/20_scalarref.t
+t/21_disable_fields.t
+t/22_undef.t
t/data/form1.html
META.yml Module meta-data (added by MakeMaker)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/META.yml new/HTML-FillInForm-2.00/META.yml
--- old/HTML-FillInForm-1.06/META.yml 2005-10-13 22:50:01.000000000 +0200
+++ new/HTML-FillInForm-2.00/META.yml 2007-09-12 02:21:52.000000000 +0200
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: HTML-FillInForm
-version: 1.06
+version: 2.00
version_from: lib/HTML/FillInForm.pm
installdirs: site
requires:
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/README new/HTML-FillInForm-2.00/README
--- old/HTML-FillInForm-1.06/README 2003-06-11 00:33:58.000000000 +0200
+++ new/HTML-FillInForm-2.00/README 2007-08-02 21:05:26.000000000 +0200
@@ -16,7 +16,7 @@
See:
http://rpmfind.net/linux/RPM/cooker/cooker/i586/Mandrake/RPMS/perl-HTML-Fill...
-Copyright (c) 2002 Thomas J. Mather, tjmather@maxmind.com
+Copyright (c) 2002-2007 Thomas J. Mather, tjmather@maxmind.com
All rights reserved. This package is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/t/04_select.t new/HTML-FillInForm-2.00/t/04_select.t
--- old/HTML-FillInForm-1.06/t/04_select.t 2004-03-08 17:06:53.000000000 +0100
+++ new/HTML-FillInForm-2.00/t/04_select.t 2007-09-12 02:13:42.000000000 +0200
@@ -36,9 +36,7 @@
foo3 => '' }
);
-my $fif = new HTML::FillInForm;
-my $output = $fif->fill(scalarref => \$hidden_form_in,
- fobject => $q);
+my $output = HTML::FillInForm->fill(\$hidden_form_in, $q);
my $is_selected = join(" ",map { m/selected/ ? "yes" : "no" } grep /option/, split ("\n",$output));
@@ -75,7 +73,7 @@
foo3 => '' }
);
-$fif = new HTML::FillInForm;
+my $fif = new HTML::FillInForm;
$output = $fif->fill(scalarref => \$hidden_form_in,
fobject => $q);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/t/10_escape.t new/HTML-FillInForm-2.00/t/10_escape.t
--- old/HTML-FillInForm-1.06/t/10_escape.t 2004-03-08 17:06:53.000000000 +0100
+++ new/HTML-FillInForm-2.00/t/10_escape.t 2007-09-12 02:13:42.000000000 +0200
@@ -1,8 +1,8 @@
# -*- Mode: Perl; -*-
+use Test::More 'no_plan';
use strict;
-print "1..1\n";
use HTML::FillInForm;
my $html =<<"__HTML__";
@@ -29,16 +29,11 @@
my %fdat = ();
-my $fif = HTML::FillInForm->new;
-my $output = $fif->fill(scalarref => \$html,
- fdat => \%fdat);
+my $output = HTML::FillInForm->fill( \$html, \%fdat);
# FIF changes order of HTML attributes, so split strings and sort
my $strings_output = join("\n", sort split(/[\s><]+/, lc($output)));
my $strings_html = join("\n", sort split(/[\s><]+/, lc($html)));
-unless ($strings_output eq $strings_html){
- print "not ";
-}
-print "ok 1";
+is($strings_output,$strings_html);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/t/11_target.t new/HTML-FillInForm-2.00/t/11_target.t
--- old/HTML-FillInForm-1.06/t/11_target.t 2002-08-29 23:53:37.000000000 +0200
+++ new/HTML-FillInForm-2.00/t/11_target.t 2007-09-12 02:20:58.000000000 +0200
@@ -2,7 +2,7 @@
use strict;
use Test;
-BEGIN { plan tests => 3 }
+BEGIN { plan tests => 8 }
use HTML::FillInForm;
@@ -16,6 +16,9 @@
<FORM>
<INPUT TYPE="TEXT" NAME="foo3" value="nada">
</FORM>
+<FORM id="foo4">
+<INPUT TYPE="TEXT" NAME="foo4" value="nada">
+</FORM>
EOF
;
@@ -23,12 +26,10 @@
foo1 => 'bar1',
foo2 => 'bar2',
foo3 => 'bar3',
+ foo4 => 'bar4',
);
-my $fif = new HTML::FillInForm;
-my $output = $fif->fill(
- scalarref => \$form,
- fdat => \%fdat,
+my $output = HTML::FillInForm->fill( \$form, \%fdat,
target => 'foo2',
);
@@ -36,3 +37,14 @@
ok($v[0], 'nada');
ok($v[1], 'bar2');
ok($v[2], 'nada');
+ok($v[3], 'nada');
+
+my $output2 = HTML::FillInForm->fill( \$form, \%fdat,
+ target => 'foo4',
+);
+
+my @v2 = $output2 =~ m/ 30;
+use Test::More tests => 38;
use_ok('HTML::FillInForm');
@@ -38,9 +38,9 @@
ignore_fields => 'one',
);
-ok($result =~ /not disturbed.+one/,'scalar value of ignore_fields');
-ok($result =~ /new val 2.+two/,'fill_scalarref worked');
-ok($result =~ /new val 3.+three/,'fill_scalarref worked 2');
+like($result, qr/not disturbed.+one/,'scalar value of ignore_fields');
+like($result, qr/new val 2.+two/,'fill_scalarref worked');
+like($result, qr/new val 3.+three/,'fill_scalarref worked 2');
$html = qq[
@@ -52,30 +52,80 @@
my @html_array = split /\n/, $html;
-$result = HTML::FillInForm->new->fill_arrayref(
- \@html_array,
- fdat => {
- one => "new val 1",
- two => "new val 2",
- },
- );
-ok($result =~ /new val 1.+one/, 'fill_arrayref 1');
-ok($result =~ /new val 2.+two/, 'fill_arrayref 2');
-
-
-$result = HTML::FillInForm->new->fill_file(
- "t/data/form1.html",
- fdat => {
- one => "new val 1",
- two => "new val 2",
- three => "new val 3",
- },
- );
-
-ok($result =~ /new val 1.+one/,'fill_file 1');
-ok($result =~ /new val 2.+two/,'fill_file 2');
-ok($result =~ /new val 3.+three/,'fill_file 3');
+{
+ $result = HTML::FillInForm->new->fill_arrayref(
+ \@html_array,
+ fdat => {
+ one => "new val 1",
+ two => "new val 2",
+ },
+ );
+
+ like($result, qr/new val 1.+one/, 'fill_arrayref 1');
+ like($result, qr/new val 2.+two/, 'fill_arrayref 2');
+}
+
+{
+ $result = HTML::FillInForm->fill(
+ \@html_array,
+ {
+ one => "new val 1",
+ two => "new val 2",
+ },
+ );
+
+ like($result, qr/new val 1.+one/, 'fill_arrayref 1');
+ like($result, qr/new val 2.+two/, 'fill_arrayref 2');
+}
+
+{
+
+ $result = HTML::FillInForm->new->fill_file(
+ "t/data/form1.html",
+ fdat => {
+ one => "new val 1",
+ two => "new val 2",
+ three => "new val 3",
+ },
+ );
+
+ like($result, qr/new val 1.+one/,'fill_file 1');
+ like($result, qr/new val 2.+two/,'fill_file 2');
+ like($result, qr/new val 3.+three/,'fill_file 3');
+}
+
+{
+ $result = HTML::FillInForm->fill(
+ "t/data/form1.html",
+ {
+ one => "new val 1",
+ two => "new val 2",
+ three => "new val 3",
+ },
+ );
+
+ like($result, qr/new val 1.+one/,'fill_file 1');
+ like($result, qr/new val 2.+two/,'fill_file 2');
+ like($result, qr/new val 3.+three/,'fill_file 3');
+}
+{
+ my $fh = open FH, "fill(
+ \*FH,
+ {
+ one => "new val 1",
+ two => "new val 2",
+ three => "new val 3",
+ },
+ );
+
+ like($result, qr/new val 1.+one/,'fill_file 1');
+ like($result, qr/new val 2.+two/,'fill_file 2');
+ like($result, qr/new val 3.+three/,'fill_file 3');
+ close($fh);
+}
@@ -92,8 +142,6 @@
);
};
-#ok($@ =~ 'HTML::FillInForm->fillInForm\(\) called without \'fobject\' or \'fdat\' parameter set', "no fdat or fobject parameters");
-
$result = HTML::FillInForm->new->fill(
fdat => {}
);
@@ -117,7 +165,7 @@
);
};
-ok($@ =~ 'HTML::FillInForm->fill called with fobject option, containing object of type Support::Object which lacks a param\(\) method!', "bad fobject parameter");
+like($@, qr/HTML::FillInForm->fill called with fobject option, containing object of type Support::Object which lacks a param\(\) method!/, "bad fobject parameter");
$html = qq{<INPUT TYPE="radio" NAME="foo1">
@@ -129,7 +177,7 @@
$result = HTML::FillInForm->new->fill(scalarref => \$html,
fdat => \%fdat);
-ok($result =~ /on.+foo1/,'defaulting radio buttons to on');
+like($result, qr/on.+foo1/,'defaulting radio buttons to on');
$html = qq{<INPUT TYPE="password" NAME="foo1">
@@ -140,7 +188,7 @@
$result = HTML::FillInForm->new->fill(scalarref => \$html,
fdat => \%fdat);
-ok($result =~ /bar2.+foo1/,'first array element taken for password fields');
+like($result, qr/bar2.+foo1/,'first array element taken for password fields');
$html = qq{<INPUT TYPE="radio" NAME="foo1" value="bar2">
@@ -190,8 +238,8 @@
fdat => \%fdat);
ok($result !~ m/checked/, "Empty radio button value");
-ok($result =~ m#<TEXTAREA NAME="foo2"></TEXTAREA>#, "Empty textarea");
-ok($result =~ m//, "Empty password field value");
+like($result, qr#<TEXTAREA NAME="foo2"></TEXTAREA>#, "Empty textarea");
+like($result, qr//, "Empty password field value");
$html = qq[<div></div>
@@ -212,12 +260,12 @@
$result = HTML::FillInForm->new->fill(scalarref => \$html,
fdat => \%fdat);
-ok($result =~ /bar1.+foo0/,'form with comments 1');
-ok($result =~ '<TEXTAREA NAME="foo1">bar2</TEXTAREA>','form with comments 2');
-ok($result =~ '<!--Comment 1-->','Comment 1');
-ok($result =~ '<!--Comment 2-->','Comment 2');
-ok($result =~ '<!--Comment\n\n3-->','Comment 3');
-ok($result =~ '<!--Comment 4-->','Comment 4');
+like($result, qr/bar1.+foo0/,'form with comments 1');
+like($result, qr'<TEXTAREA NAME="foo1">bar2</TEXTAREA>','form with comments 2');
+like($result, qr'<!--Comment 1-->','Comment 1');
+like($result, qr'<!--Comment 2-->','Comment 2');
+like($result, qr'<!--Comment\n\n3-->','Comment 3');
+like($result, qr'<!--Comment 4-->','Comment 4');
$html = qq[<div></div>
<? HTML processing instructions 1 ?>
@@ -236,10 +284,10 @@
$result = HTML::FillInForm->new->fill(scalarref => \$html,
fdat => \%fdat);
-ok($result =~ /bar1.+foo0/,'form with processing 1');
-ok($result =~ '<TEXTAREA NAME="foo1">bar2</TEXTAREA>','form with processing 2');
-ok($result =~ '<\? HTML processing instructions 1 \?>','processing 1');
-ok($result =~ '<\? XML processing instructions 2\?>','processing 2');
-ok($result =~ '<\? HTML processing instructions\n\n3>','processing 3');
-ok($result =~ '<\?HTML processing instructions 4 >','processing 4');
+like($result, qr/bar1.+foo0/,'form with processing 1');
+like($result, qr'<TEXTAREA NAME="foo1">bar2</TEXTAREA>','form with processing 2');
+like($result, qr'<\? HTML processing instructions 1 \?>','processing 1');
+like($result, qr'<\? XML processing instructions 2\?>','processing 2');
+like($result, qr'<\? HTML processing instructions\n\n3>','processing 3');
+like($result, qr'<\?HTML processing instructions 4 >','processing 4');
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/t/20_scalarref.t new/HTML-FillInForm-2.00/t/20_scalarref.t
--- old/HTML-FillInForm-1.06/t/20_scalarref.t 1970-01-01 01:00:00.000000000 +0100
+++ new/HTML-FillInForm-2.00/t/20_scalarref.t 2007-09-12 02:13:42.000000000 +0200
@@ -0,0 +1,24 @@
+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->fill( \$content, fdat => {});
+
+ is($output, $content, q{output and content should be the same});
+}
+
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/t/21_disable_fields.t new/HTML-FillInForm-2.00/t/21_disable_fields.t
--- old/HTML-FillInForm-1.06/t/21_disable_fields.t 1970-01-01 01:00:00.000000000 +0100
+++ new/HTML-FillInForm-2.00/t/21_disable_fields.t 2007-09-12 01:52:39.000000000 +0200
@@ -0,0 +1,38 @@
+#!/usr/local/bin/perl
+
+# contributed by Trevor Schellhorn
+
+use strict;
+use warnings FATAL => 'all';
+
+use Test::More tests => 5;
+
+use_ok('HTML::FillInForm');
+
+my $html = qq[
+<form>
+<input type="text" name="one" value="not disturbed">
+<input type="text" name="two" value="not disturbed">
+</form>
+];
+
+my $result = HTML::FillInForm->new->fill(
+ scalarref => \$html,
+ fdat => {
+ two => "new val 2",
+ },
+ disable_fields => [qw(two)],
+ );
+
+ok($result =~ /not disturbed.+one/,'don\'t disable 1');
+ok($result =~ /new val 2.+two.+disable="1"/,'disable 2');
+$result = HTML::FillInForm->new->fill(
+ scalarref => \$html,
+ fdat => {
+ two => "new val 2",
+ },
+ disable_fields => 'two',
+ );
+
+ok($result =~ /not disturbed.+one/,'don\'t disable 1');
+ok($result =~ /new val 2.+two.+disable="1"/,'disable 2');
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/HTML-FillInForm-1.06/t/22_undef.t new/HTML-FillInForm-2.00/t/22_undef.t
--- old/HTML-FillInForm-1.06/t/22_undef.t 1970-01-01 01:00:00.000000000 +0100
+++ new/HTML-FillInForm-2.00/t/22_undef.t 2007-08-02 19:55:53.000000000 +0200
@@ -0,0 +1,137 @@
+# -*- Mode: Perl; -*-
+
+use strict;
+
+$^W = 1;
+
+use Test::More;
+
+unless ( eval "use Test::Output; 1" ) {
+ plan skip_all => 'These tests require Test::Output';
+}
+
+plan tests => 10;
+
+
+use_ok('HTML::FillInForm');
+
+{
+ my $html = qq[
+<form>
+<input type="text" name="one" value="">
+</form>
+];
+
+ stderr_is( sub { fill( $html, undef ) },
+ '',
+ 'no warnings with undef value for input' );
+}
+
+{
+ my $html = qq[
+<form>
+<textarea name="one"></textarea>
+</form>
+];
+
+ stderr_is( sub { fill( $html, undef ) },
+ '',
+ 'no warnings with undef value for textarea' );
+}
+
+{
+ my $html = qq[
+<form>
+<select name="one"><option value="">option</option></select>
+</form>
+];
+
+ stderr_is( sub { fill( $html, undef ) },
+ '',
+ 'no warnings with undef value for select' );
+}
+
+{
+ my $html = qq[
+<form>
+<select name="one"><option value="">option</option></select>
+</form>
+];
+
+ stderr_is( sub { fill( $html, [] ) },
+ '',
+ 'no warnings with empty array value for select' );
+}
+
+{
+ my $html = qq[
+<form>
+<select name="one"><option value="">option</option></select>
+</form>
+];
+
+ stderr_is( sub { fill( $html, [ undef ] ) },
+ '',
+ 'no warnings with array containing undef for select' );
+}
+
+{
+ my $html = qq[
+<form>
+<select multiple="1" name="one"><option value="">option</option></select>
+</form>
+];
+
+ stderr_is( sub { fill( $html, undef ) },
+ '',
+ 'no warnings with undef for multi select' );
+}
+
+{
+ my $html = qq[
+<form>
+<select multiple="1" name="one"><option value="">option</option></select>
+</form>
+];
+
+ stderr_is( sub { fill( $html, [] ) },
+ '',
+ 'no warnings with empty array for multi select' );
+}
+
+{
+ my $html = qq[
+<form>
+<select multiple="1" name="one"><option value="">option</option></select>
+</form>
+];
+
+ stderr_is( sub { fill( $html, [ undef ] ) },
+ '',
+ 'no warnings with array containing undef for multi select' );
+}
+
+{
+ my $html = qq[
+<form>
+<select multiple="1" name="one"><option value="">option</option><option value="2">option 2</option></select>
+</form>
+];
+
+ stderr_is( sub { fill( $html, [ 1, undef ] ) },
+ '',
+ 'no warnings with array containing undef as second value for multi select' );
+}
+
+
+sub fill {
+ my $html = shift;
+ my $val = shift;
+
+ HTML::FillInForm->new->fill_scalarref(
+ \$html,
+ fdat => {
+ one => $val,
+ },
+ );
+}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org