Skip to content

Commit

Permalink
Fix so addr-spec with missing closing angle bracket can be parsed (#8164
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alecpl committed Aug 15, 2021
1 parent 00d52a0 commit 1660fdb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Fix handling of headers that occur multiple times by show_additional_headers plugin (#8157)
- Fix bug where vertical scrollbar in new HTML message bounced back on scroll (#8046)
- Fix displaying inline images with incorrectly declared content-type (#8158)
- Fix so addr-spec with missing closing angle bracket can be parsed (#8164)

## Release 1.5-rc

Expand Down
7 changes: 5 additions & 2 deletions program/lib/Roundcube/rcube_mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,11 @@ private static function parse_address_list($str, $decode = true, $fallback = nul
$val = substr($val, strlen($tokens[0]));
}

if (preg_match('/(.*)<('.$email_rx.')>$/', $val, $m)) {
$address = $m[2];
if (preg_match('/(.*)<('.$email_rx.')$/', $val, $m)) {
// Note: There are cases like "Test<test@domain.tld" with no closing bracket,
// therefor we do not include it in the regexp above, but we have to
// remove it later, because $email_rx will catch it (#8164)
$address = rtrim($m[2], '>');
$name = trim($m[1]);
}
else if (preg_match('/^('.$email_rx.')$/', $val, $m)) {
Expand Down
5 changes: 5 additions & 0 deletions tests/Framework/Mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ function test_decode_single_address()
24 => '"email@test.com" <>',
// valid with redundant quoting (#1490040)
25 => '"user"@"domain.tld"',
// invalid addr-spec (#8164)
26 => '"Test.org"<test@domain.tld',
27 => '<test@domain.tld',
];

$results = [
Expand Down Expand Up @@ -76,6 +79,8 @@ function test_decode_single_address()
23 => [1, 'Test,Test', 'test@domain.tld'],
24 => [1, '', 'email@test.com'],
25 => [1, '', 'user@domain.tld'],
26 => [1, 'Test.org', 'test@domain.tld'],
27 => [1, '', 'test@domain.tld'],
];

foreach ($headers as $idx => $header) {
Expand Down

0 comments on commit 1660fdb

Please sign in to comment.