diff options
-rw-r--r-- | src/cowboy_router.erl | 5 | ||||
-rw-r--r-- | test/misc_SUITE.erl | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/cowboy_router.erl b/src/cowboy_router.erl index 3451ddd..9d25442 100644 --- a/src/cowboy_router.erl +++ b/src/cowboy_router.erl @@ -325,9 +325,8 @@ split_path(Path, Acc) -> << Segment:Pos/binary, _:8, Rest/bits >> = Path, split_path(Rest, [Segment|Acc]) end - catch - error:badarg -> - badrequest + catch error:_ -> + badrequest end. remove_dot_segments([], Acc) -> diff --git a/test/misc_SUITE.erl b/test/misc_SUITE.erl index a848e44..1e0012e 100644 --- a/test/misc_SUITE.erl +++ b/test/misc_SUITE.erl @@ -39,6 +39,13 @@ init_dispatch(_) -> {"/", hello_h, []} ]}]). +router_invalid_path(Config) -> + doc("Ensure a path with invalid percent-encoded characters results in a 400."), + ConnPid = gun_open(Config), + Ref = gun:get(ConnPid, "/version/path/%\\u0016\\u0016/path"), + {response, _, 400, _} = gun:await(ConnPid, Ref), + ok. + set_env(Config) -> doc("Live replace a middleware environment value."), ConnPid1 = gun_open(Config), |