r6708 - in /branches/upstream/libhtml-fillinform-perl/current: Changes MANIFEST META.yml README lib/HTML/FillInForm.pm t/20_scalarref.t t/21_disable_fields.t t/22_undef.t

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Thu Aug 16 07:04:12 UTC 2007


Author: dmn
Date: Thu Aug 16 07:04:12 2007
New Revision: 6708

URL: http://svn.debian.org/wsvn/?sc=1&rev=6708
Log:
[svn-upgrade] Integrating new upstream version, libhtml-fillinform-perl (1.07)

Added:
    branches/upstream/libhtml-fillinform-perl/current/t/20_scalarref.t
    branches/upstream/libhtml-fillinform-perl/current/t/21_disable_fields.t
    branches/upstream/libhtml-fillinform-perl/current/t/22_undef.t
Modified:
    branches/upstream/libhtml-fillinform-perl/current/Changes
    branches/upstream/libhtml-fillinform-perl/current/MANIFEST
    branches/upstream/libhtml-fillinform-perl/current/META.yml
    branches/upstream/libhtml-fillinform-perl/current/README
    branches/upstream/libhtml-fillinform-perl/current/lib/HTML/FillInForm.pm

Modified: branches/upstream/libhtml-fillinform-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-fillinform-perl/current/Changes?rev=6708&op=diff
==============================================================================
--- branches/upstream/libhtml-fillinform-perl/current/Changes (original)
+++ branches/upstream/libhtml-fillinform-perl/current/Changes Thu Aug 16 07:04:12 2007
@@ -1,3 +1,22 @@
+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)
+
+Add support for ID attribute on form tags (name attribute is
+deprecated in xhtml) [rt.cpan.org #27376] (Anthony Ettinger)
+
+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)

Modified: branches/upstream/libhtml-fillinform-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-fillinform-perl/current/MANIFEST?rev=6708&op=diff
==============================================================================
--- branches/upstream/libhtml-fillinform-perl/current/MANIFEST (original)
+++ branches/upstream/libhtml-fillinform-perl/current/MANIFEST Thu Aug 16 07:04:12 2007
@@ -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)

Modified: branches/upstream/libhtml-fillinform-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-fillinform-perl/current/META.yml?rev=6708&op=diff
==============================================================================
--- branches/upstream/libhtml-fillinform-perl/current/META.yml (original)
+++ branches/upstream/libhtml-fillinform-perl/current/META.yml Thu Aug 16 07:04:12 2007
@@ -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:      1.07
 version_from: lib/HTML/FillInForm.pm
 installdirs:  site
 requires:

Modified: branches/upstream/libhtml-fillinform-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-fillinform-perl/current/README?rev=6708&op=diff
==============================================================================
--- branches/upstream/libhtml-fillinform-perl/current/README (original)
+++ branches/upstream/libhtml-fillinform-perl/current/README Thu Aug 16 07:04:12 2007
@@ -16,7 +16,7 @@
 See:
 http://rpmfind.net/linux/RPM/cooker/cooker/i586/Mandrake/RPMS/perl-HTML-FillInForm-0.29-2mdk.noarch.html
 
-Copyright (c) 2002 Thomas J. Mather, tjmather at maxmind.com 
+Copyright (c) 2002-2007 Thomas J. Mather, tjmather at 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. 

Modified: branches/upstream/libhtml-fillinform-perl/current/lib/HTML/FillInForm.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-fillinform-perl/current/lib/HTML/FillInForm.pm?rev=6708&op=diff
==============================================================================
--- branches/upstream/libhtml-fillinform-perl/current/lib/HTML/FillInForm.pm (original)
+++ branches/upstream/libhtml-fillinform-perl/current/lib/HTML/FillInForm.pm Thu Aug 16 07:04:12 2007
@@ -12,7 +12,7 @@
 require 5.005;
 
 use vars qw($VERSION @ISA);
-$VERSION = '1.06';
+$VERSION = '1.07';
 
 @ISA = qw(HTML::Parser);
 
@@ -38,9 +38,15 @@
     ? @{ $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{ignore_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 +95,8 @@
       $self->parse($_);
     }
   }
+
+  $self->eof;
   return delete $self->{output};
 }
 
@@ -120,6 +128,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 +144,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 +192,10 @@
     $self->{output} .= ">";
   } elsif ($tagname eq 'option'){
     my $value = $self->_get_param($self->{selectName});
-
-    if (defined($value)){
+    $value = [ $value ] unless ( ref($value) eq 'ARRAY' );
+
+    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 +203,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 +346,25 @@
 }
 
 sub comment {
-  my ( $self, $text ) = @_;
-  $self->{output} .= '<!--' . $text . '-->';
+    my ( $self, $text ) = @_;
+    # if it begins with '[if ' and doesn't end with '<![endif]'
+    # it's a "downlevel-revealed" conditional comment (stupid IE)
+    # or
+    # if it ends with '[endif]' then it's the end of a
+    # "downlevel-revealed" conditional comment
+    if(
+        (
+            ( index($text, '[if ') == 0 )
+            &&
+            ( $text !~ /<!\[endif\]$/ )
+        )
+        ||
+        ( $text eq '[endif]' )
+    ) {
+        $self->{output} .= '<!' . $text . '>';
+    } else {
+        $self->{output} .= '<!--' . $text . '-->';
+    }
 }
 
 sub process {
@@ -434,6 +475,12 @@
   $output = $fif->fill(scalarref => \$html,
                        fobject => $q,
                        ignore_fields => ['prev','next']);
+
+To disable the form from being edited, use the C<disable_fields> options:
+
+  $output = $fif->fill(scalarref => \$html,
+                       fobject => $q,
+                       disable_fields => [ 'uid', 'gid' ]);
 
 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:
@@ -547,5 +594,11 @@
   Bill Moseley
   James Tolley
   Dan Kubb
+  Alexander Hartmaier
+  Paul Miller
+  Anthony Ettinger
+  Simon P. Ditner
+  Michael Peters
+  Trevor Schellhorn
 
 Thanks!

Added: branches/upstream/libhtml-fillinform-perl/current/t/20_scalarref.t
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-fillinform-perl/current/t/20_scalarref.t?rev=6708&op=file
==============================================================================
--- branches/upstream/libhtml-fillinform-perl/current/t/20_scalarref.t (added)
+++ branches/upstream/libhtml-fillinform-perl/current/t/20_scalarref.t Thu Aug 16 07:04:12 2007
@@ -1,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});
+}
+

Added: branches/upstream/libhtml-fillinform-perl/current/t/21_disable_fields.t
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-fillinform-perl/current/t/21_disable_fields.t?rev=6708&op=file
==============================================================================
--- branches/upstream/libhtml-fillinform-perl/current/t/21_disable_fields.t (added)
+++ branches/upstream/libhtml-fillinform-perl/current/t/21_disable_fields.t Thu Aug 16 07:04:12 2007
@@ -1,0 +1,28 @@
+#!/usr/local/bin/perl
+
+# contributed by Trevor Schellhorn
+
+use strict;
+use warnings FATAL => 'all';
+
+use Test::More tests => 3;
+
+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');

Added: branches/upstream/libhtml-fillinform-perl/current/t/22_undef.t
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-fillinform-perl/current/t/22_undef.t?rev=6708&op=file
==============================================================================
--- branches/upstream/libhtml-fillinform-perl/current/t/22_undef.t (added)
+++ branches/upstream/libhtml-fillinform-perl/current/t/22_undef.t Thu Aug 16 07:04:12 2007
@@ -1,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,
+                                },
+                                );
+}




More information about the Pkg-perl-cvs-commits mailing list