From 979d1abe629bb8ad3eb31ccb860d64df4ee63bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Wed, 29 Feb 2012 13:19:57 +0000 Subject: [PATCH] Tidy all the code (make tidy) --- .../lib/Lemonldap/NG/Common/CGI.pm | 15 ++-- .../lib/Lemonldap/NG/Common/Crypto.pm | 43 +++++------ lemonldap-ng-common/t/20-Common-CGI.t | 10 +-- lemonldap-ng-common/t/35-Common-Crypto.t | 6 +- .../lib/Lemonldap/NG/Handler/Simple.pm | 71 ++++++++++--------- .../lib/Lemonldap/NG/Handler/Vhost.pm | 21 +++--- .../lib/Lemonldap/NG/Manager/Downloader.pm | 6 +- .../lib/Lemonldap/NG/Portal/AuthSAML.pm | 7 +- .../lib/Lemonldap/NG/Portal/Display.pm | 18 ++--- .../lib/Lemonldap/NG/Portal/IssuerDBOpenID.pm | 3 +- .../lib/Lemonldap/NG/Portal/IssuerDBSAML.pm | 12 ++-- .../lib/Lemonldap/NG/Portal/OpenID/SREG.pm | 3 +- .../lib/Lemonldap/NG/Portal/_LDAP.pm | 12 ++-- .../lib/Lemonldap/NG/Portal/_SAML.pm | 5 +- .../lib/Lemonldap/NG/Portal/_i18n.pm | 4 +- .../t/10-Lemonldap-NG-Portal-i18n.t | 6 +- 16 files changed, 120 insertions(+), 122 deletions(-) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm index 1e7f5b8a0..8feee1625 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm @@ -331,14 +331,15 @@ sub _sub { ##@method string extract_lang #@return array of user's preferred languages (two letters) sub extract_lang { - my $self = shift; + my $self = shift; my @langs = split /,\s*/, ( $ENV{HTTP_ACCEPT_LANGUAGE} || "" ); - my @res = (); + my @res = (); foreach (@langs) { - # languages are supposed to be sorted by preference - # only 2-letters lang tags are considered - my $lang = (split /;/)[0]; - push @res, $lang if (length($lang) == 2); + + # languages are supposed to be sorted by preference + # only 2-letters lang tags are considered + my $lang = ( split /;/ )[0]; + push @res, $lang if ( length($lang) == 2 ); } return \@res; } @@ -359,7 +360,7 @@ sub translate_template { # Test if a translation is available for the selected language # If not available, return the first translated string # - foreach (@{ $self->{lang} }) { + foreach ( @{ $self->{lang} } ) { if ( $$text_ref =~ m/$_=\"(.*?)\"/ ) { $$text_ref =~ s//$1/gx; return; diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Crypto.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Crypto.pm index aa5a22ff8..3dd37dcc3 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Crypto.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Crypto.pm @@ -23,11 +23,11 @@ our $msg; # @param mode Crypt::Rijndael constant # @return Lemonldap::NG::Common::Crypto object sub new { - my ($class, $key, $mode) = @_; + my ( $class, $key, $mode ) = @_; $mode ||= Crypt::Rijndael::MODE_CBC(); my $self = { - key => $key, - mode => $mode, + key => $key, + mode => $mode, ciphers => {} }; return bless $self, $class; @@ -40,10 +40,10 @@ sub new { # @param key that secondary key # @return Crypt::Rijndael object sub _getCipher { - my ($self, $key) = @_; + my ( $self, $key ) = @_; $key ||= ""; $self->{ciphers}->{$key} ||= - Crypt::Rijndael->new(($self->{key})^$key, $self->{mode}); + Crypt::Rijndael->new( ( $self->{key} ) ^ $key, $self->{mode} ); return $self->{ciphers}->{$key}; } @@ -56,11 +56,9 @@ sub encrypt { # pad $data so that its length be multiple of 16 bytes my $l = bytes::length($data) % 16; - $data .= "\0" x ( 16 - $l ) unless ($l == 0); + $data .= "\0" x ( 16 - $l ) unless ( $l == 0 ); - eval { - $data = encode_base64( $self->_getCipher->encrypt( $data ) ); - }; + eval { $data = encode_base64( $self->_getCipher->encrypt($data) ); }; if ($@) { $msg = "Crypt::Rijndael error : $@"; return undef; @@ -77,7 +75,7 @@ sub encrypt { # @param data datas to decrypt in Base64 format # @return decrypted datas sub decrypt { - my ($self, $data) = @_; + my ( $self, $data ) = @_; $data =~ s/%2B/\+/ig; $data =~ s/%2F/\//ig; $data =~ s/%3D/=/ig; @@ -104,8 +102,8 @@ sub decrypt { # @param key optional secondary key # @return encrypted datas in hexadecimal data sub encryptHex { - my ($self, $data, $key) = @_; - return _cryptHex($self, $data, $key, "encrypt") + my ( $self, $data, $key ) = @_; + return _cryptHex( $self, $data, $key, "encrypt" ); } ## @method string decryptHex(string data, string key) @@ -116,8 +114,8 @@ sub encryptHex { # @param key optional secondary key # @return decrypted datas in hexadecimal data sub decryptHex { - my ($self, $data, $key) = @_; - return _cryptHex($self, $data, $key, "decrypt") + my ( $self, $data, $key ) = @_; + return _cryptHex( $self, $data, $key, "decrypt" ); } ## @method private string _cryptHex (string data, string key, string sub) @@ -125,18 +123,21 @@ sub decryptHex { # @param data datas to decrypt # @param key secondary key # @param sub may be "encrypt" or "decrypt" -# @return decrypted datas in hexadecimal data +# @return decrypted datas in hexadecimal data sub _cryptHex { - my ($self, $data, $key, $sub) = @_; - unless ($data =~ /^([0-9a-fA-F]{2})*$/) { - $msg = "Lemonldap::NG::Common::Crypto::${sub}Hex error : data is not hexadecimal"; + my ( $self, $data, $key, $sub ) = @_; + unless ( $data =~ /^([0-9a-fA-F]{2})*$/ ) { + $msg = +"Lemonldap::NG::Common::Crypto::${sub}Hex error : data is not hexadecimal"; return undef; } + # $data's length must be multiple of 32, # since Rijndael requires data length multiple of 16 - unless (bytes::length($data) % 32 == 0) { - $msg = "Lemonldap::NG::Common::Crypto::${sub}Hex error : data length must be multiple of 32"; - return undef; + unless ( bytes::length($data) % 32 == 0 ) { + $msg = +"Lemonldap::NG::Common::Crypto::${sub}Hex error : data length must be multiple of 32"; + return undef; } $data = pack "H*", $data; eval { $data = $self->_getCipher($key)->$sub($data); }; diff --git a/lemonldap-ng-common/t/20-Common-CGI.t b/lemonldap-ng-common/t/20-Common-CGI.t index 6586306ab..8570d47c8 100644 --- a/lemonldap-ng-common/t/20-Common-CGI.t +++ b/lemonldap-ng-common/t/20-Common-CGI.t @@ -89,11 +89,11 @@ SKIP: { ok( scalar(@$lang) == 0, 'extract_lang 1 with void "Accept-language"' ); my $cgi2; - $ENV{SCRIPT_NAME} = '/test.pl'; - $ENV{SCRIPT_FILENAME} = 't/20-Common-CGI.t'; - $ENV{REQUEST_METHOD} = 'GET'; - $ENV{REQUEST_URI} = '/'; - $ENV{QUERY_STRING} = ''; + $ENV{SCRIPT_NAME} = '/test.pl'; + $ENV{SCRIPT_FILENAME} = 't/20-Common-CGI.t'; + $ENV{REQUEST_METHOD} = 'GET'; + $ENV{REQUEST_URI} = '/'; + $ENV{QUERY_STRING} = ''; $ENV{HTTP_ACCEPT_LANGUAGE} = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'; ok( ( $cgi2 = Lemonldap::NG::Common::CGI->new() ), 'New CGI' ); ok( $lang = $cgi2->extract_lang(), 'extract_lang' ); diff --git a/lemonldap-ng-common/t/35-Common-Crypto.t b/lemonldap-ng-common/t/35-Common-Crypto.t index f8b3872ae..ed4bc61ec 100644 --- a/lemonldap-ng-common/t/35-Common-Crypto.t +++ b/lemonldap-ng-common/t/35-Common-Crypto.t @@ -33,11 +33,9 @@ foreach my $i ( 1 .. 17 ) { "Test of base64 encrypting with $i characters string" ); } -my $data = md5_hex(rand); +my $data = md5_hex(rand); my $secondKey = md5(rand); ok( - $c->decryptHex( - $c->encryptHex( $data, $secondKey ), - $secondKey ) eq $data, + $c->decryptHex( $c->encryptHex( $data, $secondKey ), $secondKey ) eq $data, "Test of hexadecimal encrypting" ); diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm index 0a7cd518b..7bd5aba3a 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm @@ -25,7 +25,7 @@ require POSIX; use CGI::Util 'expires'; use constant SAFEWRAP => ( Safe->can("wrap_code_ref") ? 1 : 0 ); use constant UNPROTECT => 1; -use constant SKIP => 2; +use constant SKIP => 2; #inherits Cache::Cache #inherits Apache::Session @@ -85,9 +85,9 @@ BEGIN { qw( MP OK REDIRECT FORBIDDEN DONE DECLINED SERVER_ERROR $useRedirectOnForbidden $useRedirectOnError ) ], - post => [qw($transform postFilter)], - cda => ['$cda'], - cookie => [ + post => [qw($transform postFilter)], + cda => ['$cda'], + cookie => [ qw( $cookieName $https $httpOnly $cookieExpiration $securedCookie $key $cipher @@ -163,7 +163,7 @@ BEGIN { threads::shared::share($key); threads::shared::share($headerList); }; -print "eval error: $@" if($@); + print "eval error: $@" if ($@); } elsif ( MP() == 1 ) { require Apache; @@ -280,11 +280,11 @@ sub lmUnsetHeaderIn { my ( $class, $r, @headers ) = splice @_; foreach my $h (@headers) { if ( MP() == 2 ) { - $r->headers_in->unset( $h ); + $r->headers_in->unset($h); } elsif ( MP() == 1 ) { $r->header_in( $h => "" ) - if ( $r->header_in($h) ); + if ( $r->header_in($h) ); } $class->lmLog( "Unset header $h", 'debug' ); } @@ -656,10 +656,11 @@ sub defaultValuesInit { # Warning: first start of handler load values from MyHanlder.pm # and lemonldap-ng.ini # These values should be erased by global configuration! - $cookieName = $args->{cookieName} || $cookieName || 'lemonldap'; - $securedCookie = - defined( $args->{securedCookie} ) ? $args->{securedCookie} : - defined($securedCookie) ? $securedCookie : 1; + $cookieName = $args->{cookieName} || $cookieName || 'lemonldap'; + $securedCookie = + defined( $args->{securedCookie} ) ? $args->{securedCookie} + : defined($securedCookie) ? $securedCookie + : 1; $whatToTrace = $args->{whatToTrace} || $whatToTrace || 'uid'; $whatToTrace =~ s/\$//g; $https = defined($https) ? $https : $args->{https}; @@ -681,10 +682,11 @@ sub defaultValuesInit { defined($useSafeJail) ? $useSafeJail : $args->{useSafeJail}; - $key ||= 'lemonldap-ng-key'; + $key ||= 'lemonldap-ng-key'; $cipher ||= Lemonldap::NG::Common::Crypto->new($key); - if ($args->{key} && ($args->{key} ne $key) ) { - $key = $args->{key}; + + if ( $args->{key} && ( $args->{key} ne $key ) ) { + $key = $args->{key}; $cipher = Lemonldap::NG::Common::Crypto->new($key); } 1; @@ -858,14 +860,14 @@ sub goToPortal { # @return Value of the cookie if found, 0 else sub fetchId { my $t = lmHeaderIn( $apacheRequest, 'Cookie' ); - my $lookForHttpCookie = - $securedCookie =~ /^(2|3)$/ && $https->{_} == 0 ; - my $value = $lookForHttpCookie ? - ( $t =~ /${cookieName}http=([^,; ]+)/o ? $1 : 0 ) : - ( $t =~ /$cookieName=([^,; ]+)/o ? $1 : 0 ) ; + my $lookForHttpCookie = $securedCookie =~ /^(2|3)$/ && $https->{_} == 0; + my $value = + $lookForHttpCookie + ? ( $t =~ /${cookieName}http=([^,; ]+)/o ? $1 : 0 ) + : ( $t =~ /$cookieName=([^,; ]+)/o ? $1 : 0 ); - $value = $cipher->decryptHex($value, "http") - if ( $value && $lookForHttpCookie && $securedCookie == 3 ); + $value = $cipher->decryptHex( $value, "http" ) + if ( $value && $lookForHttpCookie && $securedCookie == 3 ); return $value; } @@ -882,7 +884,7 @@ sub retrieveSession { # 2. search in the local cache if exists return 1 - if ( $refLocalStorage and $datas = $refLocalStorage->get($id) ); + if ( $refLocalStorage and $datas = $refLocalStorage->get($id) ); # 3. search in the central cache my %h; @@ -900,7 +902,7 @@ sub retrieveSession { # Store the session in local storage $refLocalStorage->set( $id, $datas, "10 minutes" ) - if ($refLocalStorage); + if ($refLocalStorage); untie %h; $datasUpdate = time(); @@ -967,19 +969,22 @@ sub run ($$) { } my $id; + # Try to recover cookie and user session if ( $id = $class->fetchId and $class->retrieveSession($id) ) { + # AUTHENTICATION done - my $kc = keys %$datas; # in order to detect new local macro + my $kc = keys %$datas; # in order to detect new local macro # ACCOUNTING (1. Inform Apache) $class->lmSetApacheUser( $apacheRequest, $datas->{$whatToTrace} ); # AUTHORIZATION return $class->forbidden($uri) - unless ( $class->grant($uri) ); - $class->updateStatus( $datas->{$whatToTrace}, $apacheRequest->uri, 'OK' ); + unless ( $class->grant($uri) ); + $class->updateStatus( $datas->{$whatToTrace}, + $apacheRequest->uri, 'OK' ); # ACCOUNTING (2. Inform remote application) $class->sendHeaders; @@ -994,9 +999,8 @@ sub run ($$) { $class->hideCookie; # Log - $apacheRequest->push_handlers( - PerlLogHandler => sub { $class->logGranted( $uri, $datas ); DECLINED }, - ); + $apacheRequest->push_handlers( PerlLogHandler => + sub { $class->logGranted( $uri, $datas ); DECLINED }, ); # Catch POST rules $class->transformUri($uri); @@ -1005,6 +1009,7 @@ sub run ($$) { } elsif ( $protection == UNPROTECT ) { + # Ignore unprotected URIs $class->lmLog( "No valid session but unprotected access", "debug" ); $class->updateStatus( $apacheRequest->connection->remote_ip, @@ -1015,9 +1020,11 @@ sub run ($$) { } else { + # Redirect user to the portal - $class->lmLog( "$class: No cookie found" , 'info' ) - unless ($id); + $class->lmLog( "$class: No cookie found", 'info' ) + unless ($id); + # if the cookie was fetched, a log is sent by retrieveSession() $class->updateStatus( $apacheRequest->connection->remote_ip, $apacheRequest->uri, $id ? 'EXPIRED' : 'REDIRECT' ); @@ -1406,7 +1413,7 @@ sub sendHeaders { # that would not be caught if access rule is unprotect or skip sub cleanHeaders { my ($class) = splice @_; - $class->lmUnsetHeaderIn( $apacheRequest, @{ $headerList } ); + $class->lmUnsetHeaderIn( $apacheRequest, @{$headerList} ); } ## @rmethod protected int isUnprotected() diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm index 9a6d61176..af3c29fcf 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm @@ -150,7 +150,6 @@ sub cleanHeaders { } } - ## @rmethod protected int isUnprotected() # @return 0 if URI is protected, # UNPROTECT if it is unprotected by "unprotect", @@ -191,17 +190,17 @@ sub grant { # Get user cookies and search for Lemonldap::NG cookie. # @return Value of the cookie if found, 0 else sub fetchId { - my $t = lmHeaderIn( $apacheRequest, 'Cookie' ); - my $vhost = $apacheRequest->hostname; - my $lookForHttpCookie = - $securedCookie =~ /^(2|3)$/ - && !( defined( $https->{$vhost} ) ? $https->{$vhost} : $https->{_} ); - my $value = $lookForHttpCookie ? - ( $t =~ /${cookieName}http=([^,; ]+)/o ? $1 : 0 ) : - ( $t =~ /$cookieName=([^,; ]+)/o ? $1 : 0 ) ; + my $t = lmHeaderIn( $apacheRequest, 'Cookie' ); + my $vhost = $apacheRequest->hostname; + my $lookForHttpCookie = $securedCookie =~ /^(2|3)$/ + && !( defined( $https->{$vhost} ) ? $https->{$vhost} : $https->{_} ); + my $value = + $lookForHttpCookie + ? ( $t =~ /${cookieName}http=([^,; ]+)/o ? $1 : 0 ) + : ( $t =~ /$cookieName=([^,; ]+)/o ? $1 : 0 ); - $value = $cipher->decryptHex($value, "http") - if ( $value && $lookForHttpCookie && $securedCookie == 3 ); + $value = $cipher->decryptHex( $value, "http" ) + if ( $value && $lookForHttpCookie && $securedCookie == 3 ); return $value; } diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Downloader.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Downloader.pm index c3944a9d3..362beaf80 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Downloader.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Downloader.pm @@ -170,8 +170,10 @@ sub confNode { # be translated # 2. if a regexp comment or perl expression # comment exists, it is set as text - my $text = /^\(\?#(.*?)\)/ ? $1 : - /^(.*?)##(.+)$/ ? $2 : $_ ; + my $text = + /^\(\?#(.*?)\)/ ? $1 + : /^(.*?)##(.+)$/ ? $2 + : $_; $res .= $self->li($id) . $self->span( diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthSAML.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthSAML.pm index 9bf075bc3..07992bb4f 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthSAML.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthSAML.pm @@ -780,12 +780,13 @@ sub extractFormInfo { # IDP list my @list = (); foreach ( keys %{ $self->{_idpList} } ) { - push @list, { + push @list, + { val => $_, name => $self->{_idpList}->{$_}->{name} - }; + }; } - $self->{list} = \@list; + $self->{list} = \@list; # Delete existing IDP resolution cookie push @{ $self->{cookie} }, diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Display.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Display.pm index 27450fb9e..8479238af 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Display.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Display.pm @@ -76,8 +76,8 @@ sub display { elsif ( $self->{error} == PE_REDIRECT ) { $skinfile = "redirect.tpl"; %templateParams = ( - URL => $self->{urldc}, - HIDDEN_INPUTS => $self->buildHiddenForm(), + URL => $self->{urldc}, + HIDDEN_INPUTS => $self->buildHiddenForm(), ); } @@ -92,13 +92,13 @@ sub display { utf8::decode($auth_user); %templateParams = ( - AUTH_USER => $auth_user, - AUTOCOMPLETE => $self->{portalAutocomplete}, - NEWWINDOW => $self->{portalOpenLinkInNewWindow}, - AUTH_ERROR => $self->error( $self->{menuError} ), - AUTH_ERROR_TYPE => $self->error_type( $self->{menuError} ), - DISPLAY_TAB => $self->{menuDisplayTab}, - LOGOUT_URL => "$ENV{SCRIPT_NAME}?logout=1", + AUTH_USER => $auth_user, + AUTOCOMPLETE => $self->{portalAutocomplete}, + NEWWINDOW => $self->{portalOpenLinkInNewWindow}, + AUTH_ERROR => $self->error( $self->{menuError} ), + AUTH_ERROR_TYPE => $self->error_type( $self->{menuError} ), + DISPLAY_TAB => $self->{menuDisplayTab}, + LOGOUT_URL => "$ENV{SCRIPT_NAME}?logout=1", REQUIRE_OLDPASSWORD => $self->{portalRequireOldPassword}, HIDE_OLDPASSWORD => 0, # Do not hide old password if it is required diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/IssuerDBOpenID.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/IssuerDBOpenID.pm index d3c62c4c1..765c9e089 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/IssuerDBOpenID.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/IssuerDBOpenID.pm @@ -238,8 +238,7 @@ sub _openIDResponse { $self->info( '

' . sprintf( - $self->msg(PM_OPENID_EXCHANGE), - $data->{trust_root} + $self->msg(PM_OPENID_EXCHANGE), $data->{trust_root} ) . "

" ); diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/IssuerDBSAML.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/IssuerDBSAML.pm index 7f01a7f9f..aa53ed8e8 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/IssuerDBSAML.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/IssuerDBSAML.pm @@ -194,9 +194,9 @@ sub issuerForUnAuthUser { # Create a back link on SP displayed on login page my $html = - "referer() . "\">" - . $self->msg(PM_BACKTOSP) - . ""; + "referer() . "\">" + . $self->msg(PM_BACKTOSP) . ""; $self->loginInfo($html); return PE_OK; @@ -1708,11 +1708,7 @@ sub issuerForAuthUser { . " width=\"0\" height=\"0\" frameborder=\"0\">" . ""; - $self->info( - "

" - . $self->msg(PM_CDC_WRITER) - . "

" - ); + $self->info( "

" . $self->msg(PM_CDC_WRITER) . "

" ); $self->info($cdc_iframe); } diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/OpenID/SREG.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/OpenID/SREG.pm index 329501a5b..8a8c6239e 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/OpenID/SREG.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/OpenID/SREG.pm @@ -91,8 +91,7 @@ sub sregHook { ); $self->info( - '

' . sprintf( $self->msg(PM_OPENID_RPNS), $k ) . '

' - ); + '

' . sprintf( $self->msg(PM_OPENID_RPNS), $k ) . '

' ); return ( 0, {} ); } } diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm index 042c39b69..084647e73 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm @@ -168,20 +168,16 @@ sub userBind { # Get expiration warning and graces if ( $resp->grace_authentications_remaining ) { - $self->{portal}->info( - "

" + $self->{portal}->info( "

" . $resp->grace_authentications_remaining . " " . $self->msg(PM_PP_GRACE) - . "

" - ); + . "" ); } if ( $resp->time_before_expiration ) { - $self->{portal}->info( - "

" + $self->{portal}->info( "

" . $resp->time_before_expiration . " " . $self->msg(PM_PP_EXP_WARNING) - . "

" - ); + . "" ); } my $pp_error = $resp->pp_error; diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SAML.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SAML.pm index 9157f98d7..40b71d4e8 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SAML.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SAML.pm @@ -2637,8 +2637,7 @@ sub sendLogoutRequestToProviders { # Header of the block which will be displayed to the user, if needed. $info .= '

' - . $self->msg (Lemonldap::NG::Portal::Simple::PM_SAML_SPLOGOUT) - . '

' + . $self->msg(Lemonldap::NG::Portal::Simple::PM_SAML_SPLOGOUT) . '' . ''; # Foreach SP found in session, get it from configuration, and send the @@ -2746,7 +2745,7 @@ sub checkDestination { # Retrieve full URL my $portal = $self->{portal}; - $portal =~ s#^(https?://[^/]+)/.*#$1#; # remove path of portal URL + $portal =~ s#^(https?://[^/]+)/.*#$1#; # remove path of portal URL $url = $portal . $url; # Compare Destination and URL diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm index 999d25588..afc33b8c2 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm @@ -16,7 +16,7 @@ our $VERSION = '1.2.0'; # @return Message string in the first matching language sub msg { my ( $msg, $lang ) = splice @_; - foreach ( @{ $lang } ) { + foreach ( @{$lang} ) { if ( __PACKAGE__->can("msg_$_") ) { return &{"msg_$_"}->[$msg]; } @@ -31,7 +31,7 @@ sub msg { sub error { my ( $error, $lang ) = splice @_; $error = 0 if ( $error < 0 ); - foreach ( @{ $lang } ) { + foreach ( @{$lang} ) { if ( __PACKAGE__->can("error_$_") ) { return &{"error_$_"}->[$error]; } diff --git a/lemonldap-ng-portal/t/10-Lemonldap-NG-Portal-i18n.t b/lemonldap-ng-portal/t/10-Lemonldap-NG-Portal-i18n.t index d56912f87..0ef16270d 100644 --- a/lemonldap-ng-portal/t/10-Lemonldap-NG-Portal-i18n.t +++ b/lemonldap-ng-portal/t/10-Lemonldap-NG-Portal-i18n.t @@ -32,13 +32,13 @@ foreach ( keys %tr_err ) { my $p1 = bless {}, 'Lemonldap::NG::Portal::Simple'; $p1->{error} = 10; -$p1->{lang} = ['en', 'fr']; +$p1->{lang} = [ 'en', 'fr' ]; my $p2 = bless {}, 'Lemonldap::NG::Portal::Simple'; $p2->{error} = 5; -$p2->{lang} = []; +$p2->{lang} = []; my $p3 = bless {}, 'Lemonldap::NG::Portal::Simple'; $p3->{error} = 10; -$p3->{lang} = ['fr', 'es', 'en']; +$p3->{lang} = [ 'fr', 'es', 'en' ]; ok( $p1->error() eq $p2->error(10), 'HTTP_ACCEPT_LANGUAGE mechanism 1' ); ok( $p1->error() ne $p2->error(), 'HTTP_ACCEPT_LANGUAGE mechanism 2' );