Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code tidying #486

Merged
merged 1 commit into from
Dec 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 48 additions & 50 deletions src/lib/Sympa/List.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5794,25 +5794,24 @@ sub _load_list_members_from_include {
}

my $include_member;
my %parsing;
my %parsing;

$parsing{'data'} = $entry->{'source_parameters'};
$parsing{'template'} = "$entry->{'source'}\.incl";
$parsing{'data'} = $entry->{'source_parameters'};
$parsing{'template'} = "$entry->{'source'}\.incl";

my $name = "$entry->{'source'}\.incl";
my $name = "$entry->{'source'}\.incl";

my $include_path = $include_file;
if ($include_path =~ s/$name$//) {
$parsing{'include_path'} = $include_path;
$include_member =
$self->_load_include_admin_user_file($include_path,
\%parsing);
} else {
$log->syslog('err',
'Errors to get path of the the file %s.incl',
$entry->{'source'});
return undef;
}
my $include_path = $include_file;
if ($include_path =~ s/$name$//) {
$parsing{'include_path'} = $include_path;
$include_member =
$self->_load_include_admin_user_file($include_path,
\%parsing);
} else {
$log->syslog('err', 'Errors to get path of the the file %s.incl',
$entry->{'source'});
return undef;
}

if ($include_member and %$include_member) {
foreach my $type (@sources_providing_listmembers) {
Expand Down Expand Up @@ -6078,25 +6077,24 @@ sub _load_list_admin_from_include {
}

my $include_admin_user;
my %parsing;
my %parsing;

$parsing{'data'} = $entry->{'source_parameters'};
$parsing{'template'} = "$entry->{'source'}\.incl";
$parsing{'data'} = $entry->{'source_parameters'};
$parsing{'template'} = "$entry->{'source'}\.incl";

my $name = "$entry->{'source'}\.incl";
my $name = "$entry->{'source'}\.incl";

my $include_path = $include_file;
if ($include_path =~ s/$name$//) {
$parsing{'include_path'} = $include_path;
$include_admin_user =
$self->_load_include_admin_user_file($include_path,
\%parsing);
} else {
$log->syslog('err',
'Errors to get path of the the file %s.incl',
$entry->{'source'});
return undef;
}
my $include_path = $include_file;
if ($include_path =~ s/$name$//) {
$parsing{'include_path'} = $include_path;
$include_admin_user =
$self->_load_include_admin_user_file($include_path,
\%parsing);
} else {
$log->syslog('err', 'Errors to get path of the the file %s.incl',
$entry->{'source'});
return undef;
}

foreach my $type (@sources_providing_listmembers) {
defined $total or last;
Expand Down Expand Up @@ -6269,28 +6267,28 @@ sub _load_include_admin_user_file {
my %include;
my (@paragraphs);

my @data = split(',', $parsing->{'data'}) if defined $parsing->{'data'};
my $vars = {'param' => \@data};
my $output = '';
my @data = split(',', $parsing->{'data'}) if defined $parsing->{'data'};
my $vars = {'param' => \@data};
my $output = '';

my $template =
Sympa::Template->new(undef,
include_path => [$parsing->{'include_path'}]);
unless ($template->parse($vars, $parsing->{'template'}, \$output)) {
$log->syslog('err', 'Failed to parse %s', $parsing->{'template'});
return undef;
}
my $template =
Sympa::Template->new(undef,
include_path => [$parsing->{'include_path'}]);
unless ($template->parse($vars, $parsing->{'template'}, \$output)) {
$log->syslog('err', 'Failed to parse %s', $parsing->{'template'});
return undef;
}

my @lines = split('\n', $output);
my @lines = split('\n', $output);

my $i = 0;
foreach my $line (@lines) {
if ($line =~ /^\s*$/) {
$i++ if $paragraphs[$i];
} else {
push @{$paragraphs[$i]}, $line;
}
my $i = 0;
foreach my $line (@lines) {
if ($line =~ /^\s*$/) {
$i++ if $paragraphs[$i];
} else {
push @{$paragraphs[$i]}, $line;
}
}

for my $index (0 .. $#paragraphs) {
my @paragraph = @{$paragraphs[$index]};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Sympa/Tools/Text.pm
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ sub encode_filesystem_safe {
}

sub encode_html {
my $str = shift;
my $str = shift;
my $additional_unsafe = shift || '';

HTML::Entities::encode_entities($str, '<>&"' . $additional_unsafe);
Expand Down
58 changes: 29 additions & 29 deletions src/sbin/sympa.pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,32 @@ srand(time());
my %options;
unless (
GetOptions(
\%main::options, 'dump=s',
'debug|d', 'log_level=s',
'config|f=s', 'lang|l=s',
'mail|m', 'help|h',
'version|v', 'import=s',
'make_alias_file', 'lowercase',
'sync_list_db', 'md5_encode_password',
'close_list=s', 'rename_list=s', 'copy_list=s',
'new_listname=s', 'new_listrobot=s',
'purge_list=s', 'create_list',
'instantiate_family=s', 'robot=s',
'add_list=s', 'modify_list=s',
'close_family=s', 'md5_digest=s',
'change_user_email', 'current_email=s',
'new_email=s', 'input_file=s',
'sync_include=s', 'upgrade',
'upgrade_shared', 'from=s',
'to=s', 'reload_list_config',
'list=s', 'quiet',
'close_unknown', 'test_database_message_buffer',
'conf_2_db', 'export_list',
'health_check', 'send_digest',
'keep_digest', 'upgrade_config_location',
'role=s', 'dump_users',
'restore_users', 'open_list=s',
\%main::options, 'dump=s',
'debug|d', 'log_level=s',
'config|f=s', 'lang|l=s',
'mail|m', 'help|h',
'version|v', 'import=s',
'make_alias_file', 'lowercase',
'sync_list_db', 'md5_encode_password',
'close_list=s', 'rename_list=s',
'copy_list=s', 'new_listname=s',
'new_listrobot=s', 'purge_list=s',
'create_list', 'instantiate_family=s',
'robot=s', 'add_list=s',
'modify_list=s', 'close_family=s',
'md5_digest=s', 'change_user_email',
'current_email=s', 'new_email=s',
'input_file=s', 'sync_include=s',
'upgrade', 'upgrade_shared',
'from=s', 'to=s',
'reload_list_config', 'list=s',
'quiet', 'close_unknown',
'test_database_message_buffer', 'conf_2_db',
'export_list', 'health_check',
'send_digest', 'keep_digest',
'upgrade_config_location', 'role=s',
'dump_users', 'restore_users',
'open_list=s',
)
) {
pod2usage(-exitval => 1, -output => \*STDERR);
Expand Down Expand Up @@ -631,14 +632,13 @@ if ($main::options{'dump'} or $main::options{'dump_users'}) {
exit 1;
}
exit 0;

} elsif ($main::options{'copy_list'}) {
my $current_list =
Sympa::List->new(split(/\@/, $main::options{'copy_list'}, 2),
{just_try => 1});
unless ($current_list) {
printf STDERR "Incorrect list name %s\n",
$main::options{'copy_list'};
printf STDERR "Incorrect list name %s\n", $main::options{'copy_list'};
exit 1;
}

Expand All @@ -663,7 +663,7 @@ if ($main::options{'dump'} or $main::options{'dump_users'}) {
action => 'move_list',
current_list => $current_list,
listname => $listname,
mode => 'copy',
mode => 'copy',
sender => Sympa::get_address($robot_id, 'listmaster'),
scenario_context => {skip => 1},
);
Expand Down