diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-03-07 08:01:59 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-03-07 08:01:59 +0000 |
commit | b9f749b5529af985abcb53681244416fe8e2b4cc (patch) | |
tree | 12f6788fe8e747b82b444779bbdf48295a3c939d /src/couchdb/couch_httpd_external.erl | |
parent | a91a4fe1110b78a6f893e139c7867b04dd4f3b02 (diff) |
json startkey, endkey, and key should be decoded before being sent to the query server or externals
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@919949 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_external.erl')
-rw-r--r-- | src/couchdb/couch_httpd_external.erl | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/couchdb/couch_httpd_external.erl b/src/couchdb/couch_httpd_external.erl index fb099350..2ef2be35 100644 --- a/src/couchdb/couch_httpd_external.erl +++ b/src/couchdb/couch_httpd_external.erl @@ -77,7 +77,7 @@ json_req_obj(#httpd{mochi_req=Req, {<<"id">>, DocId}, {<<"method">>, Method}, {<<"path">>, Path}, - {<<"query">>, to_json_terms(Req:parse_qs())}, + {<<"query">>, json_query_keys(to_json_terms(Req:parse_qs()))}, {<<"headers">>, to_json_terms(Hlist)}, {<<"body">>, Body}, {<<"peer">>, ?l2b(Req:get(peer))}, @@ -95,6 +95,19 @@ to_json_terms([{Key, Value} | Rest], Acc) when is_atom(Key) -> to_json_terms([{Key, Value} | Rest], Acc) -> to_json_terms(Rest, [{list_to_binary(Key), list_to_binary(Value)} | Acc]). +json_query_keys({Json}) -> + json_query_keys(Json, []). +json_query_keys([], Acc) -> + {lists:reverse(Acc)}; +json_query_keys([{<<"startkey">>, Value} | Rest], Acc) -> + json_query_keys(Rest, [{<<"startkey">>, couch_util:json_decode(Value)}|Acc]); +json_query_keys([{<<"endkey">>, Value} | Rest], Acc) -> + json_query_keys(Rest, [{<<"endkey">>, couch_util:json_decode(Value)}|Acc]); +json_query_keys([{<<"key">>, Value} | Rest], Acc) -> + json_query_keys(Rest, [{<<"key">>, couch_util:json_decode(Value)}|Acc]); +json_query_keys([Term | Rest], Acc) -> + json_query_keys(Rest, [Term|Acc]). + send_external_response(#httpd{mochi_req=MochiReq}=Req, Response) -> #extern_resp_args{ code = Code, |