Merge remote-tracking branch 'origin/topic/timw/fix-email-regex'

* origin/topic/timw/fix-email-regex:
  Reverts the regex change in dead3226a5.
This commit is contained in:
Jon Siwek 2020-11-19 18:09:01 -08:00
commit 8d0f2f9ab7
5 changed files with 23 additions and 5 deletions

View file

@ -1,3 +1,11 @@
3.3.0-dev.554 | 2020-11-19 18:09:01 -0800
* Reverts the SMTP regex change in dead3226a545e264072ced40284f86ac41528ba8. (Tim Wojtulewicz, Corelight)
The regex change broke some of the external tests. I added some more cases
to the regular email btest to hopefully cover all of the cases better.
3.3.0-dev.551 | 2020-11-17 15:01:04 -0700
* Added unit tests for regex fix (christina23)

View file

@ -1 +1 @@
3.3.0-dev.551
3.3.0-dev.554

View file

@ -19,7 +19,7 @@ function extract_email_addrs_vec(str: string): string_vec
##
## str: A string potentially containing email addresses.
##
## Returns: A set of extracted email addresses. An empty set is returned
## Returns: A set of extracted email addresses. An empty set is returned
## if no email addresses are discovered.
function extract_email_addrs_set(str: string): set[string]
{
@ -58,8 +58,7 @@ function extract_first_email_addr(str: string): string
function split_mime_email_addresses(line: string): set[string]
{
local output = string_set();
local addrs = find_all(line, /(\"[^"]*\")?[^,]+@[^,]+/);
local addrs = find_all(line, /(\"[^"]*\")?[^,]+/);
for ( part in addrs )
{
add output[strip(part)];

View file

@ -1,3 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
one@example.com
[one@example.com, two@example.com, three@example.com, one@example.com]
{
@ -22,6 +23,12 @@ two@example.com
john.smith@email.com
[john.smith@email.com, jane.doe@email.com]
{
john.smith@email.com
john.smith@email.com,
jane.doe@email.com
}
john.smith@email.com
[john.smith@email.com, jane.doe@email.com]
{
john.smith@email.com,
jane.doe@email.com
}

View file

@ -19,3 +19,7 @@ s = "\"Smith, John\" <john.smith@email.com>, \"Doe, Jane\" <jane.doe@email.com>"
print extract_first_email_addr(s);
print extract_email_addrs_vec(s);
print extract_email_addrs_set(s);
s = "\"Smith, John\" <john.smith@email.com>,\"Doe, Jane\" <jane.doe@email.com>";
print extract_first_email_addr(s);
print extract_email_addrs_vec(s);
print extract_email_addrs_set(s);