diff options
-rw-r--r-- | lib/JWebmail.pm | 14 | ||||
-rw-r--r-- | lib/JWebmail/Controller/Webmail.pm | 4 | ||||
-rw-r--r-- | lib/JWebmail/I18N.pm | 4 | ||||
-rw-r--r-- | lib/JWebmail/Model/ReadMails/MockJSON.pm | 6 | ||||
-rw-r--r-- | lib/JWebmail/Model/ReadMails/QMailAuthuser.pm | 3 | ||||
-rw-r--r-- | lib/JWebmail/Model/WriteMails.pm | 6 | ||||
-rw-r--r-- | lib/JWebmail/Plugin/Helper.pm | 5 | ||||
-rw-r--r-- | lib/JWebmail/Plugin/INIConfig.pm | 2 | ||||
-rw-r--r-- | lib/JWebmail/Plugin/ServerSideSessionData.pm | 18 |
9 files changed, 32 insertions, 30 deletions
diff --git a/lib/JWebmail.pm b/lib/JWebmail.pm index 8c01596..1c66001 100644 --- a/lib/JWebmail.pm +++ b/lib/JWebmail.pm @@ -39,8 +39,7 @@ sub startup { $self->moniker('jwebmail'); - my $mode = $self->mode; - $self->log->path($self->home->child('log', "$mode.log")); + $self->log->path($self->home->child('log', $self->mode . '.log')); # load plugins push @{$self->plugins->namespaces}, 'JWebmail::Plugin'; @@ -57,10 +56,10 @@ sub startup { # initialize models my $read_mails = do { - if ($mode eq 'development') { + if ($self->mode eq 'development') { my $cls = $self->config->{development}{read_mock}; eval { load $cls; 1 } || die "Issue for module $cls with: $@"; - $cls->new; + $cls->new(); } else { JWebmail::Model::ReadMails::QMailAuthuser->new( @@ -72,10 +71,15 @@ sub startup { unless $read_mails->DOES('JWebmail::Model::ReadMails::Role'); $self->helper(users => sub { $read_mails }); $self->helper(send_mail => sub { my ($c, $mail) = @_; JWebmail::Model::WriteMails::sendmail($mail) }); - $JWebmail::Model::WriteMails::Block_Writes = 1 if $mode eq 'development'; + $JWebmail::Model::WriteMails::Block_Writes = 1 if $self->mode eq 'development'; $self->defaults(version => __PACKAGE__->VERSION); + $self->sessions->cookie_name('jwebmail_session'); + $self->sessions->samesite('Strict'); + $self->sessions->secure(1); + $self->sessions->default_expiration(30 * 60); + $self->route($i18n_route); } diff --git a/lib/JWebmail/Controller/Webmail.pm b/lib/JWebmail/Controller/Webmail.pm index ce18de8..b094a43 100644 --- a/lib/JWebmail/Controller/Webmail.pm +++ b/lib/JWebmail/Controller/Webmail.pm @@ -31,7 +31,7 @@ sub auth { my $self = shift; my $user = $self->session(S_USER); - my ($pw, $ch) = $self->session_passwd; + my ($pw, $ch) = $self->session_passwd(); unless ($user && $pw) { $self->flash(message => $self->l('No active session.')); @@ -249,7 +249,7 @@ sub sendmail { attach => scalar $v->optional('attach', 'non_empty_ul')->upload->param, from => scalar $self->stash(ST_AUTH)->{user}, ); - $mail{attach_type} = Mojolicious::Types->new->file_type($mail{attach}->filename) if $mail{attach}; + $mail{attach_type} = Mojolicious::Types->new()->file_type($mail{attach}->filename) if $mail{attach}; if ($v->has_error) { $self->log->debug("mail send failed. Error in @{ $v->failed }"); diff --git a/lib/JWebmail/I18N.pm b/lib/JWebmail/I18N.pm index 190f4be..190a988 100644 --- a/lib/JWebmail/I18N.pm +++ b/lib/JWebmail/I18N.pm @@ -14,7 +14,7 @@ sub init { $self->fail_with('log_on_failure'); } -sub fallback_languages { return (); } +sub fallback_languages { qw() } sub log_on_failure { my $self = shift; @@ -44,5 +44,3 @@ __END__ =head1 NAME JWebmail::L10N - Base class for internationalization - -=cut diff --git a/lib/JWebmail/Model/ReadMails/MockJSON.pm b/lib/JWebmail/Model/ReadMails/MockJSON.pm index 1a16ef6..b90a630 100644 --- a/lib/JWebmail/Model/ReadMails/MockJSON.pm +++ b/lib/JWebmail/Model/ReadMails/MockJSON.pm @@ -3,10 +3,10 @@ package JWebmail::Model::ReadMails::MockJSON; use v5.24; use warnings; use utf8; +use autodie; use List::Util 'sum'; - -use Mojo::JSON 'decode_json'; +use JSON::PP 'decode_json'; use Digest::HMAC_MD5 'hmac_md5_hex'; use Role::Tiny::With; @@ -28,7 +28,7 @@ sub _read_json_file { use constant PREFIX => 't/private/'; - open(my $body_file, '<', PREFIX . $file_name); + open my $body_file, '<', PREFIX . $file_name; local $/; my $body = <$body_file>; close $body_file; diff --git a/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm b/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm index d0d2b3c..39d8ab6 100644 --- a/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm +++ b/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm @@ -190,10 +190,9 @@ sub execute { binmode $reader, ':encoding(UTF-8)'; my $input = <$reader>; - close $reader + close $reader # waits for the child to finish or die 'closing read pipe failed'; - waitpid($pid, 0); my $rc = $? >> 8; my $resp; diff --git a/lib/JWebmail/Model/WriteMails.pm b/lib/JWebmail/Model/WriteMails.pm index f4d09e8..05c4cd1 100644 --- a/lib/JWebmail/Model/WriteMails.pm +++ b/lib/JWebmail/Model/WriteMails.pm @@ -29,7 +29,7 @@ sub _build_mail { content_type => $mail->{attach_type}, encoding => 'base64', }, - body => $mail->{attach}->asset->slurp, + body => $mail->{attach}->asset->slurp(), ) : undef; my $email = Email::MIME->create( @@ -44,7 +44,7 @@ sub _build_mail { $email->header_str_set(CC => @{$mail->{cc}}) if $mail->{cc}; $email->header_str_set('Reply-To' => $mail->{reply}) if $mail->{reply}; - return $email->as_string; + return $email->as_string(); } @@ -53,7 +53,7 @@ sub _send { open(my $m, '|-', 'sendmail', '-i', @recipients) or die 'Connecting to sendmail failed. Is it in your PATH?'; - $m->print($mime->as_string); + $m->print($mime->as_string()); close($m); return $? >> 8; } diff --git a/lib/JWebmail/Plugin/Helper.pm b/lib/JWebmail/Plugin/Helper.pm index 8323a61..ad5c8ad 100644 --- a/lib/JWebmail/Plugin/Helper.pm +++ b/lib/JWebmail/Plugin/Helper.pm @@ -178,8 +178,9 @@ sub session_passwd { if (length $passwd < 20) { $passwd .= "\n" . ' ' x (20 - length($passwd) - 1); } - my $rand_bytes = _rand_data(length $passwd); - $c->s3d(S_PASSWD, b64_encode(encode('UTF-8', $passwd) ^ $rand_bytes, '')); + my $passwd_utf8 = encode('UTF-8', $passwd); + my $rand_bytes = _rand_data(length $passwd_utf8); + $c->s3d(S_PASSWD, b64_encode($passwd_utf8 ^ $rand_bytes, '')); $c->session(S_OTP_S3D_PW, b64_encode($rand_bytes, '')); } else { diff --git a/lib/JWebmail/Plugin/INIConfig.pm b/lib/JWebmail/Plugin/INIConfig.pm index be9841e..08e1ef1 100644 --- a/lib/JWebmail/Plugin/INIConfig.pm +++ b/lib/JWebmail/Plugin/INIConfig.pm @@ -9,7 +9,7 @@ use Config::Tiny; sub parse { my ($self, $content, $file, $conf, $_app) = @_; - my $ct = Config::Tiny->new; + my $ct = Config::Tiny->new(); my $config = $ct->read_string($content, 'utf8'); die qq{Can't parse config "$file": } . $ct->errstr unless defined $config; diff --git a/lib/JWebmail/Plugin/ServerSideSessionData.pm b/lib/JWebmail/Plugin/ServerSideSessionData.pm index 94e8f25..c28f6d1 100644 --- a/lib/JWebmail/Plugin/ServerSideSessionData.pm +++ b/lib/JWebmail/Plugin/ServerSideSessionData.pm @@ -42,7 +42,7 @@ sub _rw_cleanup_file { close $lock; chomp $pid; if (!$rmlock && (!$pid || !-e "/proc/$pid")) { - $lock_name->remove; + $lock_name->remove(); $rmlock = 1; next; } @@ -60,7 +60,7 @@ sub _rw_cleanup_file { use autodie; open(my $info, -e $info_name ? '+<' : '+>', $info_name); - my $next_time = $info->getline // ''; + my $next_time = $info->getline() // ''; $next_time = 0 unless $next_time =~ /^\d+$/a; chomp $next_time; if ($next_time > $time) { @@ -77,7 +77,7 @@ sub _rw_cleanup_file { return 1; } }; - $lock_name->remove; + $lock_name->remove(); return $ret; } @@ -89,7 +89,7 @@ sub cleanup_files { if ($self->_next_cleanup < $t && $self->_rw_cleanup_file($t)) { for ($self->session_directory->list->each) { if ( $_->stat->mtime + $self->expiration < $t ) { - $_->remove; + $_->remove(); } } } @@ -102,7 +102,7 @@ sub s3d { my ($key, $val) = @_; # cleanup old sessions - $self->cleanup_files; + $self->cleanup_files(); my $file = $self->session_directory->child($c->session(S_KEY) || $c->req->request_id . $$); @@ -111,16 +111,16 @@ sub s3d { truncate $file, 0; } else { - $file->touch; + $file->touch(); } } elsif (defined $val) { - $file->touch; + $file->touch(); $file->chmod(0600); $c->session(S_KEY, $file->basename); } - my $data = -s $file ? decode_json($file->slurp) : {}; + my $data = -s $file ? decode_json($file->slurp()) : {}; if (defined $val) { # set $data->{$key} = $val; @@ -147,7 +147,7 @@ sub register { or $! ? die "failed to create directory: $!" : 1; } - $self->cleanup_files; + $self->cleanup_files(); $app->helper( s3d => sub { $self->s3d(@_) } ); $app->helper( s3d_close => sub { delete shift->session->{S_KEY()} } ); |