Skip to content

Commit

Permalink
tyidyall
Browse files Browse the repository at this point in the history
  • Loading branch information
ikedas committed Feb 24, 2020
1 parent 69c9e74 commit 649a0bc
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 175 deletions.
9 changes: 4 additions & 5 deletions src/lib/Sympa/ConfDef.pm
Original file line number Diff line number Diff line change
Expand Up @@ -969,12 +969,11 @@ our @params = (
'message_header,message_header.mime,message_footer,message_footer.mime,info',
'vhost' => '1',
},
{
'name' => 'family_signoff',
{ 'name' => 'family_signoff',
'gettext_id' => 'Global unsubscription',
'default' => 'auth', # Compat. to <=6.2.52
'scenario' => 1,
'vhost' => '1',
'default' => 'auth', # Compat. to <=6.2.52
'scenario' => 1,
'vhost' => '1',
},

{'gettext_id' => 'Tag based spam filtering'},
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Sympa/Family.pm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ sub get_uncompellable_param {
# OUT : -directory name or undef if the directory does not exist
sub _get_directory {
$log->syslog('debug3', '(%s)', @_);
my $self = shift;
my $self = shift;

my $name = $self->{'name'};
my $robot = $self->{'domain'};
Expand Down
62 changes: 37 additions & 25 deletions src/lib/Sympa/Message.pm
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,7 @@ sub check_dkim_signature {
return unless $Mail::DKIM::Verifier::VERSION;

my $robot_id =
(ref $self->{context} eq 'Sympa::List')
? $self->{context}->{'domain'}
(ref $self->{context} eq 'Sympa::List') ? $self->{context}->{'domain'}
: (ref $self->{context} eq 'Sympa::Family')
? $self->{context}->{'domain'}
: $self->{context};
Expand Down Expand Up @@ -1575,9 +1574,9 @@ sub personalize_text {
my $listname = $list->{'name'};
my $robot_id = $list->{'domain'};

$data->{'listname'} = $listname;
$data->{'domain'} = $robot_id;
$data->{'robot'} = $data->{'domain'}; # Compat.<=6.2.52.
$data->{'listname'} = $listname;
$data->{'domain'} = $robot_id;
$data->{'robot'} = $data->{'domain'}; # Compat.<=6.2.52.
$data->{'wwsympa_url'} = Conf::get_robot_conf($robot_id, 'wwsympa_url');

my $message_output;
Expand Down Expand Up @@ -2096,7 +2095,9 @@ sub _urlize_parts {

## Only multipart/mixed messages are modified.
my $eff_type = $entity->effective_type || 'text/plain';
unless ($eff_type eq 'multipart/mixed' or $eff_type eq 'multipart/alternative' or $eff_type eq 'multipart/related') {
unless ($eff_type eq 'multipart/mixed'
or $eff_type eq 'multipart/alternative'
or $eff_type eq 'multipart/related') {
return undef;
}

Expand All @@ -2121,23 +2122,34 @@ sub _urlize_sub_parts {
my $entity = shift;
my $list = shift;
my $message_id = shift;
my $directory = shift;
my $i = shift;
my @parts = ();
my $directory = shift;
my $i = shift;
my @parts = ();
use Data::Dumper;
my $parent_eff_type = $entity->effective_type();

foreach my $part ($entity->parts) {
my $eff_type = $part->effective_type || 'text/plain';
if ($eff_type eq 'multipart/mixed') {
$i++;
my $p = _urlize_sub_parts($part->dup, $list, $message_id, $directory, $i);
my $p =
_urlize_sub_parts($part->dup, $list, $message_id, $directory,
$i);
push @parts, $p;
} elsif (($eff_type eq 'multipart/alternative' or $eff_type eq 'multipart/related') and $i < 2) {
} elsif (
( $eff_type eq 'multipart/alternative'
or $eff_type eq 'multipart/related'
)
and $i < 2
) {
$i++;
my $p = _urlize_sub_parts($part->dup, $list, $message_id, $directory, $i);
my $p =
_urlize_sub_parts($part->dup, $list, $message_id, $directory,
$i);
push @parts, $p;
} else {
my $p = _urlize_one_part($part->dup, $list, $directory, $i, $parent_eff_type);
my $p = _urlize_one_part($part->dup, $list, $directory, $i,
$parent_eff_type);
if (defined $p) {
push @parts, $p;
$i++;
Expand All @@ -2146,18 +2158,18 @@ sub _urlize_sub_parts {
}
}
}

$entity->parts(\@parts);
return $entity;
}

sub _urlize_one_part {
my $entity = shift;
my $list = shift;
my $dir = shift;
my $i = shift;
my $parent_eff_type = shift;
my $entity = shift;
my $list = shift;
my $dir = shift;
my $i = shift;
my $parent_eff_type = shift;

return undef unless ($parent_eff_type eq 'multipart/mixed');

my $expl = $list->{'dir'} . '/urlized';
Expand All @@ -2173,13 +2185,13 @@ sub _urlize_one_part {
$filename = Encode::encode_utf8($filename)
if Encode::is_utf8($filename);
} else {
my $content_disposition = lc($entity->head->mime_attr('Content-Disposition') // '');
my $content_disposition =
lc($entity->head->mime_attr('Content-Disposition') // '');
if ($entity->effective_type =~ m{\Atext}
&& (!$content_disposition
|| $content_disposition eq 'attachment'
)
&& ( !$content_disposition
|| $content_disposition eq 'attachment')
&& $entity->head->mime_attr('content-type.charset')
){
) {
return undef;
}
my $fileExt = Conf::get_mime_type($entity->effective_type || '')
Expand Down
4 changes: 1 addition & 3 deletions src/lib/Sympa/Message/Template.pm
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ sub new {
$data->{'list'}{'domain'} = $list->{'domain'};
$data->{'list'}{'host'} = $list->{'domain'};
} elsif ($family) {
$data->{family} = {
name => $family->{'name'},
};
$data->{family} = {name => $family->{'name'},};
}

# Sign mode
Expand Down
12 changes: 8 additions & 4 deletions src/lib/Sympa/Scenario.pm
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ sub _compile_scenario {
my $required = join "\n", map {
my $req;
if ($_ eq 'list_object') {
$req = 'die "No list context" unless ref $that eq \'Sympa::List\';';
$req =
'die "No list context" unless ref $that eq \'Sympa::List\';';
} elsif ($_ eq 'message') {
$req = '$context->{message} ||= Sympa::Message->new("\n");';
} else {
Expand Down Expand Up @@ -671,7 +672,8 @@ sub _compile_condition {
$log->syslog('err', 'Bad regexp /%s/: %s', $re, $EVAL_ERROR);
return undef;
}
$value = sprintf 'Sympa::Scenario::safe_qr(\'%s\', $context)', $re;
$value = sprintf 'Sympa::Scenario::safe_qr(\'%s\', $context)',
$re;
} elsif ($value =~ /\[custom_vars\-\>([\w\-]+)\]/i) {
# Custom vars
$value = sprintf '$context->{custom_vars}{\'%s\'}', $1;
Expand Down Expand Up @@ -766,11 +768,13 @@ sub _compile_condition {
## available.
if (defined $index) {
$value =
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); $h[%s] // \'\' }',
sprintf
'do { my @h = $context->{message}->get_header(\'%s\'); $h[%s] // \'\' }',
$field_name, $index;
} else {
$value =
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); @h ? [@h] : [\'\'] }',
sprintf
'do { my @h = $context->{message}->get_header(\'%s\'); @h ? [@h] : [\'\'] }',
$field_name;
}
$required_keys{message} = 1;
Expand Down
9 changes: 7 additions & 2 deletions src/lib/Sympa/Spindle/ProcessAutomatic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,13 @@ sub _twist {
$log->syslog('err', 'Cannot create dynamic list %s', $listname);
return undef;
} elsif (
not( $spindle_req->success
and $list = Sympa::List->new($listname, $dyn_family->{'domain'}, {just_try => 1}))
not($spindle_req->success
and $list = Sympa::List->new(
$listname,
$dyn_family->{'domain'},
{just_try => 1}
)
)
) {
$log->syslog('err',
'Unable to create list %s. Message %s ignored',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Sympa/Template.pm
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ sub _url_func {

my $that = $self->{context};
my $robot_id =
(ref $that eq 'Sympa::List') ? $that->{'domain'}
(ref $that eq 'Sympa::List') ? $that->{'domain'}
: (ref $that eq 'Sympa::Family') ? $that->{'domain'}
: ($that and $that ne '*') ? $that
: '*';
Expand Down
6 changes: 2 additions & 4 deletions t/Message_smime.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use Test::More;
use Sympa::Log;
use Sympa::Message;

%Conf::Conf = (
sender_headers => 'From',
);
%Conf::Conf = (sender_headers => 'From',);

Sympa::Log->instance->{log_to_stderr} = 'err';

Expand All @@ -26,7 +24,7 @@ Sympa::Log->instance->{log_to_stderr} = 'err';

# is_signed()
is test_is_signed('t/samples/unsigned.eml'), 0, 'never signed';
is test_is_signed('t/samples/signed.eml'), 1, 'multipart/signed S/MIME';
is test_is_signed('t/samples/signed.eml'), 1, 'multipart/signed S/MIME';
#is test_is_signed('t/samples/signed-pkcs7.eml'), 1, 'PKCS#7 S/MIME';
#is test_is_signed('t/samples/signed-pgp.eml'), 0, 'multipart/signed PGP/MIME';
#is test_is_signed('t/samples/signed-pgp-inline.eml'), 0, 'PGP inline';
Expand Down
Loading

0 comments on commit 649a0bc

Please sign in to comment.