Unverified Commit 1bb7ad66 authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #675 from ldidry/fix-672 by ldidry

Add ability to forbid some list names (#675)
parents 39e3006a 0da705e3
......@@ -632,6 +632,9 @@ Warning: this message may already have been sent by one of the list's moderators
[%~ ELSIF report_entry == 'missing_arg' ~%]
[%|loc(report_param.argument)%]Missing argument %1[%END%]
[%~ ELSIF report_entry == 'prohibited_listname' ~%]
[%|loc(report_param.argument)%]The name you want to use for your list (%1) is prohibited by the configuration of the server.[%END%]
[%~ ELSIF report_entry == 'missing_post_source' ~%]
[%|loc()%]You didn't define the web page you want to use to create your newsletter. Please specify either an URL or a file to upload.[%END%]
......
......@@ -135,6 +135,30 @@ sub check_new_listname {
{new_listname => $listname});
}
# Prevent to use prohibited listnames
my $regex = '';
if ($Conf::Conf{'prohibited_listnames_regex'}) {
$regex = eval(sprintf 'qr(%s)',
$Conf::Conf{'prohibited_listnames_regex'} // '');
}
if ($Conf::Conf{'prohibited_listnames'}) {
foreach my $l (split ',', $Conf::Conf{'prohibited_listnames'}) {
$l =~ s/([^\s\w\x80-\xff])/\\$1/g;
$l =~ s/(\\.)/$1 eq "\\*" ? '.*' : $1/eg;
$l = sprintf('^%s$', $l);
if ($regex) {
$regex .= '|' . $l;
} else {
$regex .= $l;
}
}
}
if ($regex && $listname =~ m/$regex/i) {
$log->syslog('err', 'Prohibited "%s"', $listname);
return ('user', 'prohibited_listname', {argument => $listname});
}
# Check listname on SMTP server.
my $aliases =
Sympa::Aliases->new(Conf::get_robot_conf($robot_id, 'alias_manager'));
......
......@@ -4427,6 +4427,28 @@ our %pinfo = (
occurrence => '0-n',
},
prohibited_listnames => {
context => [qw(site)],
order => 90.00_035,
group => 'other',
gettext_id =>
'Prevent people to use some names for their lists names',
gettext_comment =>
'This parameter is a comma-separated list of names. You can use * as a wildcard character. To use a regex for this, please use prohibited_listnames_regex setting.',
sample => 'www,root,*master',
#XXXsplit_char => ',',
},
prohibited_listnames_regex => {
context => [qw(site)],
order => 90.00_036,
group => 'other',
gettext_id =>
'Prevent people to use some names for their lists names, based on a regex',
gettext_comment =>
'This parameter is a regex. Please note that prohibited_listnames and prohibited_listnames_regex will both be applied if set, they are not exclusive.',
sample => 'www|root|.*master',
},
cache_list_config => {
order => 90.00_04,
context => [qw(site)],
......
......@@ -81,6 +81,7 @@ sub _twist {
return undef;
}
}
# The 'other' topic means no topic.
$param->{topics} = lc $param->{topics};
delete $param->{topics} if $param->{topics} eq 'other';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment