mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Make sure a path parsing error in the router gives a 400
This commit is contained in:
parent
b2bd9ccfb5
commit
6fc05a6d64
2 changed files with 9 additions and 3 deletions
|
@ -325,9 +325,8 @@ split_path(Path, Acc) ->
|
||||||
<< Segment:Pos/binary, _:8, Rest/bits >> = Path,
|
<< Segment:Pos/binary, _:8, Rest/bits >> = Path,
|
||||||
split_path(Rest, [Segment|Acc])
|
split_path(Rest, [Segment|Acc])
|
||||||
end
|
end
|
||||||
catch
|
catch error:_ ->
|
||||||
error:badarg ->
|
badrequest
|
||||||
badrequest
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
remove_dot_segments([], Acc) ->
|
remove_dot_segments([], Acc) ->
|
||||||
|
|
|
@ -39,6 +39,13 @@ init_dispatch(_) ->
|
||||||
{"/", hello_h, []}
|
{"/", 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) ->
|
set_env(Config) ->
|
||||||
doc("Live replace a middleware environment value."),
|
doc("Live replace a middleware environment value."),
|
||||||
ConnPid1 = gun_open(Config),
|
ConnPid1 = gun_open(Config),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue