r50544 - in /branches/upstream/libhtml-formfu-perl/current: Changes META.yml lib/HTML/FormFu.pm lib/HTML/FormFu/Constraint/Repeatable/Any.pm lib/HTML/FormFu/Model/HashRef.pm t/elements/date_undef.t t/model/hashref_escaping.t
ansgar-guest at users.alioth.debian.org
ansgar-guest at users.alioth.debian.org
Sat Jan 9 12:27:22 UTC 2010
Author: ansgar-guest
Date: Sat Jan 9 12:26:35 2010
New Revision: 50544
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50544
Log:
[svn-upgrade] Integrating new upstream version, libhtml-formfu-perl (0.06001)
Modified:
branches/upstream/libhtml-formfu-perl/current/Changes
branches/upstream/libhtml-formfu-perl/current/META.yml
branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu.pm
branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Constraint/Repeatable/Any.pm
branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Model/HashRef.pm
branches/upstream/libhtml-formfu-perl/current/t/elements/date_undef.t
branches/upstream/libhtml-formfu-perl/current/t/model/hashref_escaping.t
Modified: branches/upstream/libhtml-formfu-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formfu-perl/current/Changes?rev=50544&op=diff
==============================================================================
--- branches/upstream/libhtml-formfu-perl/current/Changes (original)
+++ branches/upstream/libhtml-formfu-perl/current/Changes Sat Jan 9 12:26:35 2010
@@ -1,3 +1,10 @@
+0.06001 2010-01-08
+
+ - Fixed issue with Model::HashRef where form fields with an underscore
+ and overlapping name (e.g. 'foo' and 'foo_bar') were causing problems
+
+ - Fix test suite year issue.
+
0.06000 2009-12-10
- New get_parent() method that traverses the parent hierarchy, returning
Modified: branches/upstream/libhtml-formfu-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formfu-perl/current/META.yml?rev=50544&op=diff
==============================================================================
--- branches/upstream/libhtml-formfu-perl/current/META.yml (original)
+++ branches/upstream/libhtml-formfu-perl/current/META.yml Sat Jan 9 12:26:35 2010
@@ -59,4 +59,4 @@
perl: 5.8.1
resources:
license: http://dev.perl.org/licenses/
-version: 0.06000
+version: 0.06001
Modified: branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu.pm?rev=50544&op=diff
==============================================================================
--- branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu.pm (original)
+++ branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu.pm Sat Jan 9 12:26:35 2010
@@ -112,7 +112,7 @@
*plugins = \&plugin;
*add_plugins = \&add_plugin;
-our $VERSION = '0.06000';
+our $VERSION = '0.06001';
$VERSION = eval $VERSION;
Class::C3::initialize();
Modified: branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Constraint/Repeatable/Any.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Constraint/Repeatable/Any.pm?rev=50544&op=diff
==============================================================================
--- branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Constraint/Repeatable/Any.pm (original)
+++ branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Constraint/Repeatable/Any.pm Sat Jan 9 12:26:35 2010
@@ -27,11 +27,11 @@
my $repeatable = $field->get_parent({ type => 'Repeatable' });
my $pass;
- my $original_name = $field->original_name;
+ my $original_name = $field->original_name || '';
my @fields =
grep { $_->get_parent({ type => 'Repeatable' }) == $repeatable }
- grep { $_->original_name eq $original_name }
+ grep { ( $_->original_name || '' ) eq $original_name }
@{ $repeatable->get_fields };
my $increment_field_names = $repeatable->increment_field_names;
Modified: branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Model/HashRef.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Model/HashRef.pm?rev=50544&op=diff
==============================================================================
--- branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Model/HashRef.pm (original)
+++ branches/upstream/libhtml-formfu-perl/current/lib/HTML/FormFu/Model/HashRef.pm Sat Jan 9 12:26:35 2010
@@ -105,9 +105,10 @@
sub create {
my $self = shift;
if($self->form->submitted) {
+ my $input = _escape_hash($self->form->input);
my $hf = new Hash::Flatten(
{ ArrayDelimiter => '_', HashDelimiter => '.' } );
- my $input = $hf->unflatten($self->form->input);
+ $input = _unescape_hash($hf->unflatten($self->form->input));
$self->default_values( $self->_unfold_repeatable($self->form, $input) );
}
$self->form->render_data;
@@ -178,6 +179,28 @@
$self->flatten ? $names : $hf->unflatten($names) );
}
+sub _escape_hash {
+ my $hash = shift;
+ my $method = shift || \&_escape_name;
+ return $hash unless(ref $hash);
+ foreach my $k (keys %$hash) {
+ my $v = delete $hash->{$k};
+ if(ref $v eq 'HASH') {
+ $hash->{$method->($k)} = _escape_hash($v, $method);
+ } elsif(ref $v eq 'ARRAY') {
+ $hash->{$method->($k)} = [ map { _escape_hash($_, $method) } @$v];
+ } else {
+ $hash->{$method->($k)} = $v;
+ }
+ }
+ return $hash;
+}
+
+
+sub _unescape_hash {
+ return _escape_hash(shift, \&_unescape_name);
+}
+
sub _escape_name {
my $name = shift;
$name =~ s/_/\\_/g;
Modified: branches/upstream/libhtml-formfu-perl/current/t/elements/date_undef.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formfu-perl/current/t/elements/date_undef.t?rev=50544&op=diff
==============================================================================
--- branches/upstream/libhtml-formfu-perl/current/t/elements/date_undef.t (original)
+++ branches/upstream/libhtml-formfu-perl/current/t/elements/date_undef.t Sat Jan 9 12:26:35 2010
@@ -8,7 +8,7 @@
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
-$form->populate({elements => [{type => "Date", name => "foo", default => '30-08-2009'}]});
+$form->populate({elements => [{type => "Date", name => "foo", year => {list => [2009]}, default => '30-08-2009'}]});
$form->process;
@@ -16,4 +16,4 @@
$form->get_field('foo')->default(undef);
-like($form->render, qr/value="2009">/);
+like($form->render, qr/value="2009">/);
Modified: branches/upstream/libhtml-formfu-perl/current/t/model/hashref_escaping.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-formfu-perl/current/t/model/hashref_escaping.t?rev=50544&op=diff
==============================================================================
--- branches/upstream/libhtml-formfu-perl/current/t/model/hashref_escaping.t (original)
+++ branches/upstream/libhtml-formfu-perl/current/t/model/hashref_escaping.t Sat Jan 9 12:26:35 2010
@@ -1,8 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More;
+use HTML::FormFu;
use HTML::FormFu::Model::HashRef;
my %test = (
@@ -17,3 +18,55 @@
}
is( HTML::FormFu::Model::HashRef::_unescape_name('foo\\_bar'), 'foo_bar' );
+
+is_deeply(
+ HTML::FormFu::Model::HashRef::_escape_hash(
+ {
+ 'name_2' => 'foo',
+ 'name_bar_foo' => 'bar',
+ 'name_2_bar' => 'baz',
+ 'name_2.bar' => { 'bas_z' => 1 },
+ 'bar_z' => [ { foo_w => 1, foo_2 => 2 } ],
+ }
+ ),
+ {
+ 'name_2' => 'foo',
+ 'name\\_bar\\_foo' => 'bar',
+ 'name\\_2\\_bar' => 'baz',
+ 'name_2.bar' => { 'bas\\_z' => 1 },
+ 'bar\\_z' => [ { 'foo\\_w' => 1, foo_2 => 2 } ]
+ }
+);
+
+is_deeply(
+ HTML::FormFu::Model::HashRef::_unescape_hash(
+ {
+ 'name_2' => 'foo',
+ 'name\\_bar\\_foo' => 'bar',
+ 'name\\_2\\_bar' => 'baz',
+ 'name_2.bar' => { 'bas\\_z' => 1 },
+ 'bar\\_z' => [ { 'foo\\_w' => 1, foo_2 => 2 } ]
+
+ }
+ ),
+ {
+ 'name_2' => 'foo',
+ 'name_bar_foo' => 'bar',
+ 'name_2_bar' => 'baz',
+ 'name_2.bar' => { 'bas_z' => 1 },
+ 'bar_z' => [ { foo_w => 1, foo_2 => 2 } ],
+ }
+);
+
+my $form = HTML::FormFu->new;
+$form->populate(
+ {
+ elements =>
+ [ { name => 'foo' }, { name => 'bar' }, { name => 'foo_bar' } ]
+ }
+);
+$form->process( { foo => 1, bar => 2, foo_bar => 3 } );
+
+is_deeply($form->model('HashRef')->create, { foo => 1, bar => 2, foo_bar => 3 });
+
+done_testing;
More information about the Pkg-perl-cvs-commits
mailing list