Skip to content

Commit

Permalink
Item1518: perltidy
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@11609 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed May 3, 2011
1 parent 1b62762 commit 69ff6ce
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions core/lib/Foswiki/Users/HtPasswdUser.pm
Expand Up @@ -182,9 +182,11 @@ sub _readPasswd {
if ( $Foswiki::cfg{Htpasswd}{Encoding} eq 'md5' ) { # htdigest format

# implicit untaint OK; data from htpasswd
my ($hID, $hRealm, $hPasswd, $hEmail ) = $line =~ /^(.*?):(.*?):(.*?)(?::(.*))?$/;
my ( $hID, $hRealm, $hPasswd, $hEmail ) =
$line =~ /^(.*?):(.*?):(.*?)(?::(.*))?$/;

if (! $hEmail && $hPasswd =~ m/@/ ) { # Missing email and Password might contain an email address
if ( !$hEmail && $hPasswd =~ m/@/ )
{ # Missing email and Password might contain an email address
$data->{$hID}->{pass} = $hRealm;
$data->{$hID}->{emails} = $hPasswd || '';
}
Expand All @@ -193,7 +195,7 @@ sub _readPasswd {
$data->{$hID}->{emails} = $hEmail || '';
}
}
else { # htpasswd format
else { # htpasswd format
if ( $line =~ /^(.*?):(.*?)(?::(.*))?$/ ) {

# implicit untaint OK; data from htpasswd
Expand Down Expand Up @@ -229,18 +231,23 @@ sub _dumpPasswd {
sub _savePasswd {
my $db = shift;

unless (-e "$Foswiki::cfg{Htpasswd}{FileName}" ) {
# Item4544: Document special format used in .htpasswd for email addresses
open( my $readme, '>', "$Foswiki::cfg{Htpasswd}{FileName}.README" ) or
throw Error::Simple( $Foswiki::cfg{Htpasswd}{FileName}.
'.README open failed: '.$! );
unless ( -e "$Foswiki::cfg{Htpasswd}{FileName}" ) {

print $readme "# Foswiki uses a specially crafted .htpasswd file format that should not be\n";
print $readme "# manipulated using a standard htpasswd utility or loss of registered emails might occur..\n";
print $readme "# (3rd-party utilities do not support the email address format used by Foswiki).\n";
# Item4544: Document special format used in .htpasswd for email addresses
open( my $readme, '>', "$Foswiki::cfg{Htpasswd}{FileName}.README" )
or throw Error::Simple(
$Foswiki::cfg{Htpasswd}{FileName} . '.README open failed: ' . $! );

print $readme
"# Foswiki uses a specially crafted .htpasswd file format that should not be\n";
print $readme
"# manipulated using a standard htpasswd utility or loss of registered emails might occur..\n";
print $readme
"# (3rd-party utilities do not support the email address format used by Foswiki).\n";
print $readme "# \n";
print $readme "# More information available at: http://foswiki.org/System/UserAuthentication.\n";
close( $readme );
print $readme
"# More information available at: http://foswiki.org/System/UserAuthentication.\n";
close($readme);
}

my $content = _dumpPasswd($db);
Expand Down

0 comments on commit 69ff6ce

Please sign in to comment.