Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Accept more characters in local-part of e-mail address #13

Merged
merged 2 commits into from

2 participants

Arjan Scherpenisse Andrew Thompson
Arjan Scherpenisse
Collaborator

This patch by Zotonic author Marc Worrell makes the receiving SMTP server be more lenient with the parsing of the address local-part. http://en.wikipedia.org/wiki/Email_address

Andrew Thompson
Owner

If you add some tests, I'll be happy to merge this.

Arjan Scherpenisse
Collaborator

Added 2 tests with "exotic" but valid e-mail addresses.

Andrew Thompson Vagabond merged commit 48cd010 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/gen_smtp_server_session.erl
9 src/gen_smtp_server_session.erl
View
@@ -660,6 +660,11 @@ parse_encoded_address(<<H, Tail/binary>>, Acc, {false, AB}) when H >= $a, H =< $
parse_encoded_address(Tail, [H | Acc], {false, AB}); % lowercase letters
parse_encoded_address(<<H, Tail/binary>>, Acc, {false, AB}) when H =:= $-; H =:= $.; H =:= $_ ->
parse_encoded_address(Tail, [H | Acc], {false, AB}); % dash, dot, underscore
+% Allowed characters in the local name: ! # $ % & ' * + - / = ? ^ _ ` . { | } ~
+parse_encoded_address(<<H, Tail/binary>>, Acc, {false, AB}) when H =:= $+;
+ H =:= $!; H =:= $#; H =:= $$; H =:= $%; H =:= $&; H =:= $'; H =:= $*; H =:= $=;
+ H =:= $/; H =:= $?; H =:= $^; H =:= $`; H =:= ${; H =:= $|; H =:= $}; H =:= $~ ->
+ parse_encoded_address(Tail, [H | Acc], {false, AB}); % other characters
parse_encoded_address(_, _Acc, {false, _AB}) ->
error;
parse_encoded_address(<<H, Tail/binary>>, Acc, Quotes) ->
@@ -845,7 +850,9 @@ parse_encoded_address_test_() ->
?assertEqual({<<"God@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<\\God@heaven.af.mil>">>)),
?assertEqual({<<"God@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<\"God\"@heaven.af.mil>">>)),
?assertEqual({<<"God@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<@gateway.af.mil,@uucp.local:\"\\G\\o\\d\"@heaven.af.mil>">>)),
- ?assertEqual({<<"God2@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God2@heaven.af.mil>">>))
+ ?assertEqual({<<"God2@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God2@heaven.af.mil>">>)),
+ ?assertEqual({<<"God+extension@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God+extension@heaven.af.mil>">>)),
+ ?assertEqual({<<"God~*$@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God~*$@heaven.af.mil>">>))
end
},
{"Addresses that are sorta valid should parse",
Something went wrong with that request. Please try again.