diff options
author | wenwl <wenwl@cn.ibm.com> | 2018-11-28 21:43:22 +0800 |
---|---|---|
committer | jiangph <jiangph@cn.ibm.com> | 2018-12-08 09:24:50 +0800 |
commit | fcb272ef45063d651b486a5e0098be8b717c8b78 (patch) | |
tree | 6d669548874bdf003183e6ab70d1d64e76ee64d1 /src/couch | |
parent | 8077afbbf1ee78c22c76bb9772c710d8ed0df8a2 (diff) | |
download | couchdb-fcb272ef45063d651b486a5e0098be8b717c8b78.tar.gz |
Fix function_clause error
- fix function_clause error on invalid DB security objects
when the request body of PUT db/_security endpoint is not
a correct json format
Closes #1384
Diffstat (limited to 'src/couch')
-rw-r--r-- | src/couch/src/couch_db.erl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl index 2304ba1fa..0ae164d9b 100644 --- a/src/couch/src/couch_db.erl +++ b/src/couch/src/couch_db.erl @@ -750,19 +750,23 @@ validate_security_object(SecProps) -> % validate user input validate_names_and_roles({Props}) when is_list(Props) -> - case couch_util:get_value(<<"names">>,Props,[]) of + case couch_util:get_value(<<"names">>, Props, []) of Ns when is_list(Ns) -> [throw("names must be a JSON list of strings") ||N <- Ns, not is_binary(N)], Ns; - _ -> throw("names must be a JSON list of strings") + _ -> + throw("names must be a JSON list of strings") end, - case couch_util:get_value(<<"roles">>,Props,[]) of + case couch_util:get_value(<<"roles">>, Props, []) of Rs when is_list(Rs) -> [throw("roles must be a JSON list of strings") ||R <- Rs, not is_binary(R)], Rs; - _ -> throw("roles must be a JSON list of strings") + _ -> + throw("roles must be a JSON list of strings") end, - ok. + ok; +validate_names_and_roles(_) -> + throw("admins or members must be a JSON list of strings"). get_revs_limit(#db{} = Db) -> couch_db_engine:get_revs_limit(Db). |