File Coverage

blib/lib/HTML/Widget/Plugin/Password.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 6 6 100.0
pod 2 2 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1 15     15   7057 use strict;
  15         27  
  15         489  
2 15     15   65 use warnings;
  15         19  
  15         664  
3             package HTML::Widget::Plugin::Password;
4             # ABSTRACT: for SECRET input
5             $HTML::Widget::Plugin::Password::VERSION = '0.203';
6 15     15   58 use parent 'HTML::Widget::Plugin::Input';
  15         18  
  15         63  
7              
8             #pod =head1 SYNOPSIS
9             #pod
10             #pod $widget_factory->password({
11             #pod id => 'user_secret',
12             #pod value => "not visible in html",
13             #pod });
14             #pod
15             #pod =head1 DESCRIPTION
16             #pod
17             #pod This plugin provides a widget for password-entry inputs.
18             #pod
19             #pod =cut
20              
21 15     15   808 use HTML::Element;
  15         42  
  15         71  
22              
23             #pod =head1 METHODS
24             #pod
25             #pod =head2 C< provided_widgets >
26             #pod
27             #pod This plugin provides the following widgets: password
28             #pod
29             #pod =cut
30              
31 17     17 1 49 sub provided_widgets { [ input => 'password' ] }
32              
33             #pod =head2 C< password >
34             #pod
35             #pod This method returns a password-entry widget.
36             #pod
37             #pod In addition to the generic L attributes, the following
38             #pod are valid arguments:
39             #pod
40             #pod =over
41             #pod
42             #pod =item value
43             #pod
44             #pod This is the widget's initial value. The value is eaten and displayed as a
45             #pod series of spaces, if the value is defined.
46             #pod
47             #pod =back
48             #pod
49             #pod =cut
50              
51             #pod =head2 C< rewrite_arg >
52             #pod
53             #pod The password plugin's rewrite_arg replaces any non-empty value with a string of
54             #pod spaces so that passwords are not inadvertantly sent as plain text.
55             #pod
56             #pod =cut
57              
58             sub rewrite_arg {
59 3     3 1 5 my ($self, $arg, @rest) = @_;
60              
61 3         12 $arg = $self->SUPER::rewrite_arg($arg, @rest);
62              
63 3         3 $arg->{attr}{type} = "password";
64              
65 3 100 100     12 $arg->{attr}{value} = q{ } x 8
66             if defined $arg->{attr}{value} and length $arg->{attr}{value};
67              
68 3         6 return $arg;
69             }
70              
71             1;
72              
73             __END__