Merge pull request #30 from ClusterLabs/string_bugs

* Fixed a bug where Words->load_agent_strings() wouldn't process stri…
main
digimer-bot 4 years ago committed by GitHub
commit 66e0fb4490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      Anvil/Tools/Email.pm
  2. 15
      Anvil/Tools/Words.pm

@ -467,15 +467,16 @@ sub send_alerts
{
# The user wants it.
my $message = $anvil->Words->parse_banged_string({
debug => $debug,
language => $recipient_language,
key_string => $alert_message,
});
# A lot of multi-line strings start with an opening new line. This removes that.
$message =~ s/^\n//;
$message =~ s/\n$//s;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { message => $message }});
if ($alert_title)
{
my $title = "[ ".$alert_set_by." ] ".$anvil->Words->parse_banged_string({

@ -343,16 +343,19 @@ sub load_agent_strings
foreach my $agent_name (sort {$a cmp $b} keys %{$anvil->data->{scancore}{agent}})
{
my $agent_words = $anvil->data->{scancore}{agent}{$agent_name}.".xml";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { agent_words => $agent_words }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { agent_words => $agent_words }});
if ((-e $agent_words) && (-r $agent_words))
{
# Read the words file.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0251", variables => {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0251", variables => {
agent_name => $agent_name,
file => $agent_words,
}});
$anvil->Words->read({file => $agent_words});
$anvil->Words->read({
debug => $debug,
file => $agent_words,
});
}
}
@ -447,6 +450,12 @@ sub parse_banged_string
$new_string =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { new_string => $new_string }});
}
else
{
# If a string doesn't have a new-line, then copy the key string directly.
$new_string = $key_string;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { new_string => $new_string }});
}
# There might be multiple keys, split by newlines.
foreach my $message (split/\n/, $new_string)

Loading…
Cancel
Save