Skip to content
This repository
Browse code

Improve validity check for reduce qs

Allowed values are "true" and "false"; anything else is a 400.

BugzID: 14775
  • Loading branch information...
commit dbb432d8c35485d3da900ae195b8a0c7ac895ee5 1 parent 6abe8e6
Adam Kocoloski kocolosk authored rnewson committed

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

  1. +8 1 src/chttpd_view.erl
9 src/chttpd_view.erl
@@ -136,7 +136,14 @@ reverse_key_default(?MAX_STR) -> ?MIN_STR;
136 136 reverse_key_default(Key) -> Key.
137 137
138 138 get_reduce_type(Req) ->
139   - list_to_existing_atom(chttpd:qs_value(Req, "reduce", "true")).
  139 + case chttpd:qs_value(Req, "reduce", "true") of
  140 + "true" ->
  141 + true;
  142 + "false" ->
  143 + false;
  144 + Error ->
  145 + throw({bad_request, "`reduce` qs param must be `true` or `false`"})
  146 + end.
140 147
141 148 parse_view_params(Req, Keys, ViewType) when not is_list(Req) ->
142 149 QueryParams = lists:flatmap(fun({K,V}) -> parse_view_param(K,V) end,

0 comments on commit dbb432d

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