diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/JWebmail/Model/ReadMails/Role.pm | 2 | ||||
-rw-r--r-- | lib/JWebmail/Model/WriteMails.pm | 4 | ||||
-rw-r--r-- | lib/JWebmail/Plugin/ServerSideSessionData.pm | 3 |
3 files changed, 4 insertions, 5 deletions
diff --git a/lib/JWebmail/Model/ReadMails/Role.pm b/lib/JWebmail/Model/ReadMails/Role.pm index 593672c..1f4390b 100644 --- a/lib/JWebmail/Model/ReadMails/Role.pm +++ b/lib/JWebmail/Model/ReadMails/Role.pm @@ -56,7 +56,7 @@ around @methods => sub { my $succ = eval { @res = $orig->(@_); 1 }; $_[1]->{password} = $safe; die unless $succ; - return wantarray ? @res : $res[$#res]; + return wantarray ? @res : $res[-1]; }; around read_headers_for => sub { diff --git a/lib/JWebmail/Model/WriteMails.pm b/lib/JWebmail/Model/WriteMails.pm index 7a50bcb..f4d09e8 100644 --- a/lib/JWebmail/Model/WriteMails.pm +++ b/lib/JWebmail/Model/WriteMails.pm @@ -24,13 +24,13 @@ sub _build_mail { }, body_str => $mail->{message}, ); - my $attach = Email::MIME->create( + my $attach = $mail->{attach} ? Email::MIME->create( attributes => { content_type => $mail->{attach_type}, encoding => 'base64', }, body => $mail->{attach}->asset->slurp, - ) if $mail->{attach}; + ) : undef; my $email = Email::MIME->create( header_str => [ diff --git a/lib/JWebmail/Plugin/ServerSideSessionData.pm b/lib/JWebmail/Plugin/ServerSideSessionData.pm index 40772eb..94e8f25 100644 --- a/lib/JWebmail/Plugin/ServerSideSessionData.pm +++ b/lib/JWebmail/Plugin/ServerSideSessionData.pm @@ -120,10 +120,9 @@ sub s3d { $c->session(S_KEY, $file->basename); } - my $data = decode_json($file->slurp) if (-s $file); + my $data = -s $file ? decode_json($file->slurp) : {}; if (defined $val) { # set - $data = ref $data ? $data : {}; $data->{$key} = $val; $file->spurt(encode_json $data, "\n"); |