change case sensitive string match to case insensitive

With the rewrite from C to Rust the search string match was changed to
be case sensitive by accident. Fix this by comparing the lowercase values
of both the input and the search string.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
Mira Limbeck 2020-11-09 15:18:46 +01:00 committed by Thomas Lamprecht
parent 5c363ec815
commit c409629f80
3 changed files with 47 additions and 1 deletions

View File

@ -1842,7 +1842,7 @@ impl Parser {
self.string_match = false;
if !self.options.string_match.is_empty()
&& find(complete_line, self.options.string_match.as_bytes()).is_some()
&& find_lowercase(complete_line, self.options.string_match.as_bytes()).is_some()
{
self.string_match = true;
}

View File

@ -114,3 +114,26 @@ fn after_queue_search_string() {
let output_reader = BufReader::new(&output.stdout[..]);
utils::compare_output(output_reader, expected_output);
}
#[test]
fn after_queue_search_string_case_insensitive() {
let output = Command::new(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608302400")
.arg("-e")
.arg("1608303600")
.arg("-i")
.arg("tests/test_input_mixed")
.arg("-x")
.arg("reJECT")
.output()
.expect("failed to execute pmg-log-tracker");
let expected_file = File::open("tests/test_output_after_queue_search_string")
.expect("failed to open test_output");
let expected_output = BufReader::new(&expected_file);
let output_reader = BufReader::new(&output.stdout[..]);
utils::compare_output(output_reader, expected_output);
}

View File

@ -114,6 +114,29 @@ fn before_queue_search_string() {
utils::compare_output(output_reader, expected_output);
}
#[test]
fn before_queue_search_string_case_insensitive() {
let output = Command::new(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
.arg("-e")
.arg("1608302400")
.arg("-i")
.arg("tests/test_input_mixed")
.arg("-x")
.arg("reJECT")
.output()
.expect("failed to execute pmg-log-tracker");
let expected_file = File::open("tests/test_output_before_queue_search_string")
.expect("failed to open test_output");
let expected_output = BufReader::new(&expected_file);
let output_reader = BufReader::new(&output.stdout[..]);
utils::compare_output(output_reader, expected_output);
}
#[test]
fn before_queue_exclude_greylist_ndr() {
let output = Command::new(utils::log_tracker_path())