Skip to content

Commit

Permalink
fix(GODT-2185): Fix mail address parsing with & in name
Browse files Browse the repository at this point in the history
Some of the tokens were being reported to the parser which was breaking
the parsing rules.
  • Loading branch information
LBeernaertProton authored and jameshoulahan committed Dec 6, 2022
1 parent 9b6772d commit 11bf5cf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
46 changes: 23 additions & 23 deletions internal/parser/grammar/RFC5322AddressListLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@ fragment CR: '\r'; // \u000D
fragment U_0E_1F: '\u000E'..'\u001F';

// Printable (0x20-0x7E)
Exclamation: '!'; // \u0021
DQuote: '"'; // \u0022
Hash: '#'; // \u0023
Dollar: '$'; // \u0024
Percent: '%'; // \u0025
Ampersand: '&'; // \u0026
SQuote: '\''; // \u0027
LParens: '('; // \u0028
RParens: ')'; // \u0029
Asterisk: '*'; // \u002A
Plus: '+'; // \u002B
fragment Exclamation: '!'; // \u0021
fragment DQuote: '"'; // \u0022
fragment Hash: '#'; // \u0023
fragment Dollar: '$'; // \u0024
fragment Percent: '%'; // \u0025
fragment Ampersand: '&'; // \u0026
fragment SQuote: '\''; // \u0027
fragment LParens: '('; // \u0028
fragment RParens: ')'; // \u0029
fragment Asterisk: '*'; // \u002A
fragment Plus: '+'; // \u002B
Comma: ','; // \u002C
Minus: '-'; // \u002D
fragment Minus: '-'; // \u002D
Period: '.'; // \u002E
Slash: '/'; // \u002F
fragment Slash: '/'; // \u002F
fragment Digit: [0-9]; // \u0030 -- \u0039
Colon: ':'; // \u003A
Semicolon: ';'; // \u003B
Less: '<'; // \u003C
Equal: '='; // \u003D
fragment Equal: '='; // \u003D
Greater: '>'; // \u003E
Question: '?'; // \u003F
fragment Question: '?'; // \u003F
At: '@'; // \u0040
// alphaUpper
fragment LBracket: '['; // \u005B
Backslash: '\\'; // \u005C
fragment Backslash: '\\'; // \u005C
fragment RBracket: ']'; // \u005D
Caret: '^'; // \u005E
Underscore: '_'; // \u005F
Backtick: '`'; // \u0060
fragment Caret: '^'; // \u005E
fragment Underscore: '_'; // \u005F
fragment Backtick: '`'; // \u0060
// alphaLower
LCurly: '{'; // \u007B
Pipe: '|'; // \u007C
RCurly: '}'; // \u007D
Tilde: '~'; // \u007E
fragment LCurly: '{'; // \u007B
fragment Pipe: '|'; // \u007C
fragment RCurly: '}'; // \u007D
fragment Tilde: '~'; // \u007E

// Other
Delete: '\u007F';
Expand Down
9 changes: 9 additions & 0 deletions internal/parser/tests/parser/address_list_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ TEST(AddressList, ParseSingleAddressList) {
"BQA <[email protected]>",
{{"BQA", "[email protected]"}},
},
{
"Something & Something <[email protected]>",
{{"Something & Something", "[email protected]"}},
},
{
"Something - Something <[email protected]>",
{{"Something - Something", "[email protected]"}},
},
{
"[email protected]",
{{"", "[email protected]"}},
Expand Down Expand Up @@ -574,6 +582,7 @@ TEST(AddressList, Invalid) {
R"(=?windows-1250?Q?Spr=E1vce_syst=E9mu?=)",
R"("'[email protected].'")",
R"(<this is not an email address>)",
R"("Mail Delivery System <>" <@>)",
};

for (const auto& input : inputs) {
Expand Down

0 comments on commit 11bf5cf

Please sign in to comment.