Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ private function handleQuote(array &$emailAddress): void
$emailAddress['address_temp'] = '';
if ($emailAddress['address_temp_period'] > 0) {
$emailAddress['invalid'] = true;
$emailAddress['invalid_reason'] = 'Periods within the name of an email address must appear in quotes, such as "John Q. Public" <john@qpublic.com>';
$emailAddress['invalid_reason'] = 'Periods within the display name of an email address must appear in quotes, such as "John Q. Public" <john@qpublic.com> according to RFC 5322';
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions tests/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ public function testParseEmailAddresses()
// Check if test specifies use_whitespace_as_separator option
$useWhitespaceAsSeparator = $test['use_whitespace_as_separator'] ?? true;

// Configure Parse to support both comma and semicolon as separators
$options = new ParseOptions(['%', '!'], [',', ';'], $useWhitespaceAsSeparator);
// Check if test specifies custom separators
$separators = $test['separators'] ?? [',', ';'];

// Configure Parse to support configured separators
$options = new ParseOptions(['%', '!'], $separators, $useWhitespaceAsSeparator);
$parser = new Parse(null, $options);

$this->assertSame($result, $parser->parse($emails, $multiple));
Expand Down
200 changes: 199 additions & 1 deletion tests/testspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
domain: ''
ip: ''
invalid: true
invalid_reason: 'Periods within the name of an email address must appear in quotes, such as "John Q. Public" <john@qpublic.com>'
invalid_reason: 'Periods within the display name of an email address must appear in quotes, such as "John Q. Public" <john@qpublic.com> according to RFC 5322'
-
emails: 'test.testing@asdf.ghjkl.com test.testing2@asdf.ghjkl.com'
multiple: true
Expand Down Expand Up @@ -1715,3 +1715,201 @@
ip: ''
invalid: false
invalid_reason: null
-
emails: 'john@example.com;jane@example.com'
multiple: true
separators: [',']
use_whitespace_as_separator: false
result:
success: false
reason: 'Invalid email address'
email_addresses:
-
address: ''
simple_address: ''
original_address: 'john@example.com;jane@example.com'
name: ''
name_parsed: ''
local_part: john
local_part_parsed: john
domain_part: 'example.com'
domain: 'example.com'
ip: ''
invalid: true
invalid_reason: 'Invalid character found in domain of email address (please put in quotes if needed): '';'''
-
emails: 'john@example.com, jane@example.com'
multiple: true
separators: [';']
use_whitespace_as_separator: false
result:
success: false
reason: 'Invalid email address'
email_addresses:
-
address: ''
simple_address: ''
original_address: 'john@example.com, jane@example.com'
name: ''
name_parsed: ''
local_part: john
local_part_parsed: john
domain_part: 'example.com'
domain: 'example.com'
ip: ''
invalid: true
invalid_reason: 'Invalid character found in domain of email address (please put in quotes if needed): '','''
-
emails: 'john@example.com, jane@example.com'
multiple: true
separators: [',']
result:
success: true
reason: null
email_addresses:
-
address: john@example.com
simple_address: john@example.com
original_address: john@example.com
name: ''
name_parsed: ''
local_part: john
local_part_parsed: john
domain_part: example.com
domain: example.com
ip: ''
invalid: false
invalid_reason: null
-
address: jane@example.com
simple_address: jane@example.com
original_address: jane@example.com
name: ''
name_parsed: ''
local_part: jane
local_part_parsed: jane
domain_part: example.com
domain: example.com
ip: ''
invalid: false
invalid_reason: null
-
emails: 'john@example.com; jane@example.com'
multiple: true
separators: [';']
result:
success: true
reason: null
email_addresses:
-
address: john@example.com
simple_address: john@example.com
original_address: john@example.com
name: ''
name_parsed: ''
local_part: john
local_part_parsed: john
domain_part: example.com
domain: example.com
ip: ''
invalid: false
invalid_reason: null
-
address: jane@example.com
simple_address: jane@example.com
original_address: jane@example.com
name: ''
name_parsed: ''
local_part: jane
local_part_parsed: jane
domain_part: example.com
domain: example.com
ip: ''
invalid: false
invalid_reason: null
-
emails: '"Smith, John" <john@example.com>'
multiple: true
result:
success: true
reason: null
email_addresses:
-
address: '"Smith, John" <john@example.com>'
simple_address: john@example.com
original_address: '"Smith, John" <john@example.com>'
name: '"Smith, John"'
name_parsed: 'Smith, John'
local_part: john
local_part_parsed: john
domain_part: example.com
domain: example.com
ip: ''
invalid: false
invalid_reason: null
-
emails: '"Smith, John" <john@example.com>, "Doe, Jane" <jane@example.com>'
multiple: true
result:
success: true
reason: null
email_addresses:
-
address: '"Smith, John" <john@example.com>'
simple_address: john@example.com
original_address: '"Smith, John" <john@example.com>'
name: '"Smith, John"'
name_parsed: 'Smith, John'
local_part: john
local_part_parsed: john
domain_part: example.com
domain: example.com
ip: ''
invalid: false
invalid_reason: null
-
address: '"Doe, Jane" <jane@example.com>'
simple_address: jane@example.com
original_address: '"Doe, Jane" <jane@example.com>'
name: '"Doe, Jane"'
name_parsed: 'Doe, Jane'
local_part: jane
local_part_parsed: jane
domain_part: example.com
domain: example.com
ip: ''
invalid: false
invalid_reason: null
-
emails: 'Smith, John <john@example.com>'
multiple: true
result:
success: false
reason: 'Invalid email address'
email_addresses:
-
address: ''
simple_address: ''
original_address: Smith
name: ''
name_parsed: ''
local_part: ''
local_part_parsed: ''
domain_part: ''
domain: ''
ip: ''
invalid: true
invalid_reason: 'Misplaced separator or missing "@" symbol'
-
address: 'John <john@example.com>'
simple_address: john@example.com
original_address: 'John <john@example.com>'
name: John
name_parsed: John
local_part: john
local_part_parsed: john
domain_part: example.com
domain: example.com
ip: ''
invalid: false
invalid_reason: null