-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for SMTPUTF8 extension, RFC-6531 #280
Conversation
@@ -546,7 +554,7 @@ handle_request({<<"MAIL">>, Args}, | |||
?log(debug, "error: ~s~n", [Message]), | |||
send(State, Message), | |||
{ok, State}; | |||
NewState -> | |||
#state{envelope = Envelope} = NewState -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's actually a small bugfix, because we used to loose the value of #envelope.expectedsize
we set on lines 522 and 528
@@ -756,62 +764,73 @@ handle_error(Kind, Details, #state{module=Module, callbackstate = OldCallbackSta | |||
State | |||
end. | |||
|
|||
-spec parse_encoded_address(Address :: binary()) -> {binary(), binary()} | 'error'. | |||
parse_encoded_address(<<>>) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of the diff in parse_encoded_address
is just me replacing the tuple with the record (except one clause I added and changing list_to_binary
to unicode:characters_to_binary
)
parse_encoded_address(Tail, [H | Acc], {false, AB}); % dash, dot, underscore | ||
parse_encoded_address(<<H/utf8, Tail/binary>>, Acc, #pa{utf8 = true} = F) when H > 127 -> | ||
%% https://datatracker.ietf.org/doc/html/rfc6531#section-3.3 | ||
parse_encoded_address(Tail, [H | Acc], F); % UTF-8 above 7bit (when allowed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the only new clause I added
?assertEqual({<<"God2@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God2@heaven.af.mil>">>, false)), | ||
?assertEqual({<<"God+extension@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God+extension@heaven.af.mil>">>, false)), | ||
?assertEqual({<<"God~*$@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God~*$@heaven.af.mil>">>, false)), | ||
?assertEqual({<<"God~!#$%^&*()_+123@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<\"God~!#$%^&*()_+123\"@heaven.af.mil>">>, false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only extra test in "Valid addresses should parse" section, and it is not related to the PR's topic. I just noticed that quoted address is not covered by tests
I agree, supporting this is good, even if we didn't see it in the wild yet. |
https://datatracker.ietf.org/doc/html/rfc6531
It's relatively simple extension that allows SMTP clients send
MAIL FROM: <utf-8 email>
andRCPT TO: <utf-8 email>
.I never seen UTF-8 email addresses in a wild so far, but I saw many SMTP servers implementing this extension (including gmail and outlook).