* Fixed a bug where Words->load_agent_strings() wouldn't process strings without new-lines in them (caused in the last fix).

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 3f04c9031b
commit ac6531ddf2
  1. 5
      Anvil/Tools/Email.pm
  2. 15
      Anvil/Tools/Words.pm

@ -467,15 +467,16 @@ sub send_alerts
{ {
# The user wants it. # The user wants it.
my $message = $anvil->Words->parse_banged_string({ my $message = $anvil->Words->parse_banged_string({
debug => $debug,
language => $recipient_language, language => $recipient_language,
key_string => $alert_message, key_string => $alert_message,
}); });
# A lot of multi-line strings start with an opening new line. This removes that. # A lot of multi-line strings start with an opening new line. This removes that.
$message =~ s/^\n//; $message =~ s/^\n//;
$message =~ s/\n$//s; $message =~ s/\n$//s;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { message => $message }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { message => $message }});
if ($alert_title) if ($alert_title)
{ {
my $title = "[ ".$alert_set_by." ] ".$anvil->Words->parse_banged_string({ 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}}) foreach my $agent_name (sort {$a cmp $b} keys %{$anvil->data->{scancore}{agent}})
{ {
my $agent_words = $anvil->data->{scancore}{agent}{$agent_name}.".xml"; 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)) if ((-e $agent_words) && (-r $agent_words))
{ {
# Read the words file. # 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, agent_name => $agent_name,
file => $agent_words, 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$//; $new_string =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { new_string => $new_string }}); $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. # There might be multiple keys, split by newlines.
foreach my $message (split/\n/, $new_string) foreach my $message (split/\n/, $new_string)

Loading…
Cancel
Save