diff --git a/src/yaws.erl b/src/yaws.erl index 686009fa..44d88ef9 100644 --- a/src/yaws.erl +++ b/src/yaws.erl @@ -2948,12 +2948,9 @@ parse_auth(Orig = "Basic " ++ Auth64) -> {error, _Err} -> {undefined, undefined, Orig}; Auth -> - case string:tokens(Auth, ":") of - [User, Pass ] -> - {User, Pass, Orig}; - [User, Pass0 | Extra] -> - %% password can contain : - Pass = join_sep([Pass0 | Extra], ":"), + case string:split(Auth, ":") of + %% Password can contain colons, username cannot (RFC7617). + [User, Pass] when User /= [] -> {User, Pass, Orig}; _ -> {undefined, undefined, Orig} diff --git a/testsuite/auth_SUITE.erl b/testsuite/auth_SUITE.erl index a08363b6..e7022a1d 100644 --- a/testsuite/auth_SUITE.erl +++ b/testsuite/auth_SUITE.erl @@ -54,6 +54,11 @@ end_per_testcase(_Test, _Config) -> %%==================================================================== basic_auth(Config) -> + User0 = "foo", + Password0 = "::bar:::frob::::", + Auth0 = auth_header(User0, Password0), + ?assertMatch({User0, Password0, Auth0}, yaws:parse_auth(Auth0)), + Port = testsuite:get_yaws_port(1, Config), Url = testsuite:make_url(http, "127.0.0.1", Port, "/test1/a.txt"), Auth1 = auth_header("foo", "baz"),