Commit 42422124 authored by Clément OUDOT's avatar Clément OUDOT
Browse files

Fix extract_lang subroutine for Android devices (#530)

parent 12db0442
......@@ -16,7 +16,7 @@ use Encode;
#parameter syslog Indicates syslog facility for logging user actions
our $VERSION = '1.2.0';
our $VERSION = '1.2.2';
use base qw(CGI);
......@@ -339,16 +339,26 @@ 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*/, ( shift || $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
# Languages are supposed to be sorted by preference
my $lang = ( split /;/ )[0];
# Take first part of lang code (part before -)
$lang = ( split /-/, $lang )[0];
# Go to next if lang was already added
next if grep( /$lang/, @res );
# Store lang only if size is 2 characters
push @res, $lang if ( length($lang) == 2 );
}
return \@res;
}
......
......@@ -7,7 +7,7 @@
package My::Portal;
use strict;
use Test::More tests => 17;
use Test::More tests => 22;
use_ok('Lemonldap::NG::Common::CGI');
#our @ISA = qw('Lemonldap::NG::Common::CGI');
......@@ -101,6 +101,17 @@ SKIP: {
ok( $lang->[1] eq 'en', 'extract_lang' );
ok( scalar(@$lang) == 2, 'extract_lang' );
# Extract lang Android (See #LEMONLDAP-530)
my $cgi3;
$ENV{HTTP_ACCEPT_LANGUAGE} = 'fr-FR, en-US';
ok( ( $cgi3 = Lemonldap::NG::Common::CGI->new() ), 'New CGI' );
ok( $lang = $cgi3->extract_lang(), 'extract_lang Android' );
ok( $lang->[0] eq 'fr', 'extract_lang Android' );
ok( $lang->[1] eq 'en', 'extract_lang Android' );
ok( scalar(@$lang) == 2, 'extract_lang Android' );
# SOAP
eval { require SOAP::Lite };
skip "SOAP::Lite is not installed, so CGI SOAP functions will not work", 3
......
......@@ -77,6 +77,23 @@ if ( defined $conf->{samlStorage}
print "SAML backend $module will be used\n" if $debug;
}
# CAS
if ( defined $conf->{casStorage}
or keys %{ $conf->{casStorageOptions} } )
{
# Load module
$module = $conf->{casStorage} || $conf->{globalStorage};
eval "use $module";
die $@ if ($@);
$conf->{casStorageOptions}->{backend} = $module;
# Add module in managed backends
push @backends, $conf->{casStorageOptions};
print "CAS backend $module will be used\n" if $debug;
}
#=============================================================================
# Load and purge sessions
#=============================================================================
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment