Fix issue with some regexp in perl 5.26

This commit is contained in:
garnier-quentin 2019-01-11 16:15:53 +01:00
parent e0cc5b3fa3
commit 3894ad18c3
4 changed files with 9 additions and 9 deletions

View File

@ -151,14 +151,14 @@ sub display_output {
foreach my $severity (('ok', 'warning', 'critical')) {
next if (scalar(@{$self->{'values_' . $severity}}) == 0 && scalar(@{$self->{'values_string_' . $severity}}) == 0);
my $format = $self->{option_results}->{'format_' . $severity};
while ($format =~ /%{(.*?)}/g) {
while ($format =~ /%\{(.*?)\}/g) {
my $replace = '';
if (ref($self->{$1}) eq 'ARRAY') {
$replace = join($self->{option_results}->{values_separator}, @{$self->{$1}});
} else {
$replace = defined($self->{$1}) ? $self->{$1} : '';
}
$format =~ s/%{$1}/$replace/g;
$format =~ s/%\{$1\}/$replace/g;
}
$self->{output}->output_add(severity => $severity,
short_msg => $format);

View File

@ -147,14 +147,14 @@ sub display_output {
foreach my $severity (('ok', 'warning', 'critical')) {
next if (scalar(@{$self->{'values_' . $severity}}) == 0 && scalar(@{$self->{'values_string_' . $severity}}) == 0);
my $format = $self->{option_results}->{'format_' . $severity};
while ($format =~ /%{(.*?)}/g) {
while ($format =~ /%\{(.*?)\}/g) {
my $replace = '';
if (ref($self->{$1}) eq 'ARRAY') {
$replace = join($self->{option_results}->{values_separator}, @{$self->{$1}});
} else {
$replace = defined($self->{$1}) ? $self->{$1} : '';
}
$format =~ s/%{$1}/$replace/g;
$format =~ s/%\{$1\}/$replace/g;
}
$self->{output}->output_add(severity => $severity,
short_msg => $format);

View File

@ -72,7 +72,7 @@ sub custom_status_output {
while ($msg =~ /%\{(.*?)\}/g) {
my $key = $1;
if (defined($self->{result_values}->{$key})) {
$msg =~ s/%{$key}/$self->{result_values}->{$key}/g;
$msg =~ s/%\{$key\}/$self->{result_values}->{$key}/g;
}
}

View File

@ -247,10 +247,10 @@ sub build_format_details {
my $append = '';
foreach my $instance (sort keys %{$self->{instances}->{$severity}}) {
my $details = $self->{option_results}->{'format_details_' . $severity};
$details =~ s/%{rows}/$self->{macros}->{rows}/g;
$details =~ s/%{filter_rows}/$self->{macros}->{filter_rows}/g;
$details =~ s/%{instance}/$instance/g;
$details =~ s/%{value}/$self->{instances}->{$severity}->{$instance}/g;
$details =~ s/%\{rows\}/$self->{macros}->{rows}/g;
$details =~ s/%\{filter_rows\}/$self->{macros}->{filter_rows}/g;
$details =~ s/%\{instance\}/$instance/g;
$details =~ s/%\{value\}/$self->{instances}->{$severity}->{$instance}/g;
$self->{macros}->{'details_' . $severity} .= $append . $details;
$append = $self->{option_results}->{'format_details_separator_' . $severity};