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/branches/Release01x01@11611 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed May 3, 2011
1 parent 787a11f commit f3e8826
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 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,21 @@ 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: '.$! );

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 );
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: ' . $! );

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

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

0 comments on commit f3e8826

Please sign in to comment.