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

Merge pull request #833 from ikedas/issue-831 by ikedas

Scenario fails with negative indices in [header->Field][n] (#831)
parents 07d185db cc700b91
......@@ -8,8 +8,8 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018 The Sympa Community. See the AUTHORS.md file at the
# top-level directory of this distribution and at
# Copyright 2017, 2018, 2019 The Sympa Community. See the AUTHORS.md file
# at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
......@@ -583,9 +583,11 @@ sub _compile_scenario {
my $required = join "\n", map {
my $req;
if ($_ eq 'list_object') {
$req = 'return undef unless ref $that eq \'Sympa::List\';';
$req = 'die "No list context" unless ref $that eq \'Sympa::List\';';
} elsif ($_ eq 'message') {
$req = sprintf '$context->{message} ||= Sympa::Message->new("\n");';
} else {
$req = sprintf 'return undef unless exists $context->{%s};', $_;
$req = sprintf 'die "Missing parameter \'%s\'" unless exists $context->{%s};', $_, $_;
}
" $req";
} sort keys %required;
......@@ -785,7 +787,7 @@ sub _compile_condition {
## available.
if (defined $index) {
$value =
sprintf '[$context->{message}->get_header(\'%s\')]->[%s]',
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); $h[%s] }',
$field_name, $index;
} else {
$value = sprintf '[$context->{message}->get_header(\'%s\')]',
......
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