Skip to content

Commit

Permalink
Merge pull request #590 from ikedas/salaun-urennes1/fix-scenario-name…
Browse files Browse the repository at this point in the history
…-with-dots by ikedas

Additional changes to: Salaun urennes1/fix scenario name with dots (#589)
  • Loading branch information
ikedas authored Apr 14, 2019
2 parents 592ed2e + 70c9373 commit fa27473
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/cgi/wwsympa.fcgi.in
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '.*',
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Sympa/ListDef.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down
6 changes: 5 additions & 1 deletion src/lib/Sympa/Regexps.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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\-\.\+]+';
Expand Down
9 changes: 6 additions & 3 deletions src/lib/Sympa/Scenario.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit fa27473

Please sign in to comment.