summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_query_servers.erl
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-11-20 04:42:43 +0000
committerDamien F. Katz <damien@apache.org>2008-11-20 04:42:43 +0000
commit2c260766864a56e10aa45c3b1782f640b21a0bac (patch)
treeba41373450b909079755103172fb14a7ed7944c6 /src/couchdb/couch_query_servers.erl
parent8ec0f5d5407ccd9a7cee0fc579ad08d8f4be5bd7 (diff)
Nearly completed security/validation work. Still needs replication testing.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@719160 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_query_servers.erl')
-rw-r--r--src/couchdb/couch_query_servers.erl13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/couchdb/couch_query_servers.erl b/src/couchdb/couch_query_servers.erl
index 141c9406..8465a632 100644
--- a/src/couchdb/couch_query_servers.erl
+++ b/src/couchdb/couch_query_servers.erl
@@ -69,9 +69,9 @@ prompt(Port, Json) ->
true = port_command(Port, Bin),
case read_json(Port) of
{[{<<"error">>, Id}, {<<"reason">>, Reason}]} ->
- throw({list_to_atom(binary_to_list(Id)),Reason});
+ throw({Id,Reason});
{[{<<"reason">>, Reason}, {<<"error">>, Id}]} ->
- throw({list_to_atom(binary_to_list(Id)),Reason});
+ throw({Id,Reason});
Result ->
Result
end.
@@ -181,15 +181,16 @@ validate_doc_update(Lang, FunSrc, EditDoc, DiskDoc, Ctx) ->
if DiskDoc == nil ->
null;
true ->
- couch_doc:to_json_obj(EditDoc, [revs])
+ couch_doc:to_json_obj(DiskDoc, [revs])
end,
try prompt(Port,
[<<"validate">>, FunSrc, JsonEditDoc, JsonDiskDoc, Ctx]) of
1 ->
ok;
- {ErrorObject} ->
- {user_error,
- {ErrorObject}}
+ {[{<<"forbidden">>, Message}]} ->
+ throw({forbidden, Message});
+ {[{<<"unauthorized">>, Message}]} ->
+ throw({unauthorized, Message})
after
return_linked_port(Lang, Port)
end.