Skip to content
This repository
Browse code

Merge pull request #13 from zotonic/master

Accept more characters in local-part of e-mail address
  • Loading branch information...
commit 48cd01000c52d8f7cb90bff2545389b330c6d8a2 2 parents 5aba398 + 0cb4aca
Andrew Thompson authored

Showing 1 changed file with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. +8 1 src/gen_smtp_server_session.erl
9 src/gen_smtp_server_session.erl
@@ -660,6 +660,11 @@ parse_encoded_address(<<H, Tail/binary>>, Acc, {false, AB}) when H >= $a, H =< $
660 660 parse_encoded_address(Tail, [H | Acc], {false, AB}); % lowercase letters
661 661 parse_encoded_address(<<H, Tail/binary>>, Acc, {false, AB}) when H =:= $-; H =:= $.; H =:= $_ ->
662 662 parse_encoded_address(Tail, [H | Acc], {false, AB}); % dash, dot, underscore
  663 +% Allowed characters in the local name: ! # $ % & ' * + - / = ? ^ _ ` . { | } ~
  664 +parse_encoded_address(<<H, Tail/binary>>, Acc, {false, AB}) when H =:= $+;
  665 + H =:= $!; H =:= $#; H =:= $$; H =:= $%; H =:= $&; H =:= $'; H =:= $*; H =:= $=;
  666 + H =:= $/; H =:= $?; H =:= $^; H =:= $`; H =:= ${; H =:= $|; H =:= $}; H =:= $~ ->
  667 + parse_encoded_address(Tail, [H | Acc], {false, AB}); % other characters
663 668 parse_encoded_address(_, _Acc, {false, _AB}) ->
664 669 error;
665 670 parse_encoded_address(<<H, Tail/binary>>, Acc, Quotes) ->
@@ -845,7 +850,9 @@ parse_encoded_address_test_() ->
845 850 ?assertEqual({<<"God@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<\\God@heaven.af.mil>">>)),
846 851 ?assertEqual({<<"God@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<\"God\"@heaven.af.mil>">>)),
847 852 ?assertEqual({<<"God@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<@gateway.af.mil,@uucp.local:\"\\G\\o\\d\"@heaven.af.mil>">>)),
848   - ?assertEqual({<<"God2@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God2@heaven.af.mil>">>))
  853 + ?assertEqual({<<"God2@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God2@heaven.af.mil>">>)),
  854 + ?assertEqual({<<"God+extension@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God+extension@heaven.af.mil>">>)),
  855 + ?assertEqual({<<"God~*$@heaven.af.mil">>, <<>>}, parse_encoded_address(<<"<God~*$@heaven.af.mil>">>))
849 856 end
850 857 },
851 858 {"Addresses that are sorta valid should parse",

0 comments on commit 48cd010

Please sign in to comment.
Something went wrong with that request. Please try again.