do not alter option hash ref in check()
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 19 Oct 2008 14:47:33 +0000 (14:47 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 19 Oct 2008 14:47:33 +0000 (14:47 +0000)
Method check could set at least 'checked' attribute in given rows.
Passes test 53 (options var unmodified).

lib/HTML/Form/Simple.pm

index 440f4042f607104e815ec86dd0e7678e5b8bcaf5..152efe90dc534b8d22ce81fe9eb32e403e142add 100644 (file)
@@ -202,7 +202,7 @@ sub check {
        my ($name, $label, $checked, $attr) = $self->_attr(3, @_);
 
        my $rows = defined $label ? ref $label eq 'ARRAY' ? [@$label] : [$label] : [{}];
-       ref $_ eq 'HASH' or $_ = {label => $_} for @$rows;
+       $_ = ref $_ eq 'HASH' ? {%$_} : {label => $_} for @$rows;
        if (defined $checked) {
                if (ref $checked eq 'ARRAY') {
                        $rows->[$_]->{checked} = $checked->[$_] for 0 .. $#$rows;