Commit 70c9373a authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Refactoring. Use constants for regexps to check scenario names.

parent b6314019
......@@ -927,9 +927,9 @@ our %in_regexp = (
'remote_addr' => Sympa::Regexps::host(),
 
## Scenario name
'scenario' => Sympa::Regexps::scenario(),
'read_access' => Sympa::Regexps::scenario(),
'edit_access' => Sympa::Regexps::scenario(),
'scenario' => Sympa::Regexps::scenario_name(),
'read_access' => Sympa::Regexps::scenario_name(),
'edit_access' => Sympa::Regexps::scenario_name(),
## RSS URL or blank
'active_lists' => '.*',
'latest_lists' => '.*',
......
......@@ -2740,7 +2740,7 @@ sub cleanup {
$v->{format} = $format;
} elsif ($v->{'scenario'}) {
# Scenario format
$v->{'format'} = Sympa::Regexps::scenario();
$v->{'format'} = Sympa::Regexps::scenario_config();
#XXX$v->{'default'} = 'default';
} elsif ($v->{'task'}) {
# Task format
......@@ -2789,7 +2789,7 @@ sub cleanup {
$v->{'format'}{$k}{format} = $format;
} elsif ($v->{'format'}{$k}{'scenario'}) {
# Scenario format
$v->{'format'}{$k}{'format'} = Sympa::Regexps::scenario();
$v->{'format'}{$k}{'format'} = Sympa::Regexps::scenario_config();
#XXX$v->{'format'}{$k}{'default'} = 'default'
#XXX unless ($p eq 'web_archive' and $k eq 'access')
#XXX or ($p eq 'archive' and $k eq 'web_access');
......
......@@ -57,7 +57,11 @@ use constant listname => qr'[a-z0-9][a-z0-9\-\.\+_]*';
use constant ldap_attrdesc => qr'\w[-\w]*(?:;[-\w]+)*'; # RFC2251, 4.1.5
use constant sql_query => qr'(SELECT|select).*';
use constant scenario => qr'[\w,\.\-]+';
# "scenario" was deprecated. Use "scenario_name".
# "scenario_config" is used for compatibility to earlier list config files.
use constant scenario_config => qr'[-.,\w]+';
use constant scenario_name => qr'[-.\w]+';
use constant task => qr'\w+';
use constant datasource => qr'[\w-]+';
use constant uid => qr'[\w\-\.\+]+';
......
......@@ -41,6 +41,7 @@ use Sympa::Database;
use Sympa::Language;
use Sympa::List;
use Sympa::Log;
use Sympa::Regexps;
use Sympa::Robot;
use Sympa::Tools::Data;
use Sympa::Tools::File;
......@@ -107,10 +108,12 @@ sub new {
my $function = shift;
my %options = @_;
my $scenario_name_re = Sympa::Regexps::scenario_name();
# Compatibility for obsoleted use of parameter names.
$function = $compat_function_maps{$function} || $function;
die 'bug in logic. Ask developer'
unless defined $function and $function =~ /\A[-.\w]+\z/;
unless defined $function and $function =~ /\A$scenario_name_re\z/;
# Determine parameter to get the name of scenario.
# 'include' and 'topics_visibility' functions are special: They don't
......@@ -151,7 +154,7 @@ sub new {
unless (
defined $name
and ( $function eq 'include' and $name =~ m{\A[^/]+\z}
or $name =~ /\A[-\w\.]+\z/)
or $name =~ /\A$scenario_name_re\z/)
) {
$log->syslog('err', 'Unknown or undefined scenario function "%s", scenario name "%s"',
$function, $name);
......@@ -1593,7 +1596,7 @@ sub get_scenarios {
my @paths = @{Sympa::get_search_path($that, subdir => 'scenari')};
#XXXunshift @list_of_scenario_dir, $that->{'dir'} . '/scenari';
my $scenario_re = Sympa::Regexps::scenario();
my $scenario_re = Sympa::Regexps::scenario_name();
foreach my $dir (@paths) {
next unless -d $dir;
......
Markdown is supported
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