Skip to content
Snippets Groups Projects
Commit 786c0e4b authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

switch from CGI to CGI::Simple

parent 1ca8dc19
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ It is actually composed of two parts:
This is a web application developed in Perl, allowing SP admins to create test accounts with multiple user profiles.
It requires the following CPAN distributions:
* CGI
* CGI-Simple
* Config-Tiny
* DateTime
* List-MoreUtils
......
......@@ -3,7 +3,8 @@ package AccountManager::App;
use strict;
use warnings;
use CGI;
use CGI::Simple;
use CGI::Simple::Cookie;
use English qw(-no_match_vars);
use Log::Any::Adapter;
use List::MoreUtils qw(uniq);
......@@ -62,11 +63,18 @@ sub new {
}
$self->{logger} = Log::Any->get_logger();
$self->{cgi} = CGI->new();
$self->{cgi} = CGI::Simple->new();
my $lang =
$self->{cgi}->param('lang') ||
$self->{cgi}->cookie('lang');
my $lang;
my $cookies = CGI::Simple::Cookie->fetch();
if ($lang = $self->{cgi}->param('lang')) {
$self->{logger}->debugf("setting language from parameter: %s", $lang);
} elsif ($lang = $cookies->{lang} ? $cookies->{lang}->value() : undef) {
$self->{logger}->debugf("setting language from cookie: %s", $lang);
} else {
$self->{logger}->debugf("setting language from HTTP_ACCEPT_LANGUAGE header: %s", $ENV{HTTP_ACCEPT_LANGUAGE});
}
$self->{lh} = AccountManager::L10N->get_handle($lang ? $lang: ());
if (!$self->{lh}) {
$self->{logger}->fatal("Unable to get suitable language handle");
......@@ -188,7 +196,7 @@ sub respond {
binmode(STDOUT, ":utf8");
my $cookie = $self->{cgi}->cookie(
my $cookie = CGI::Simple::Cookie->new(
-name => 'lang',
-value => $self->{lh}->language_tag(),
-expires => undef,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment