couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r919949 - /couchdb/trunk/src/couchdb/couch_httpd_external.erl
Date Sun, 07 Mar 2010 08:01:59 GMT
Author: jchris
Date: Sun Mar  7 08:01:59 2010
New Revision: 919949

URL: http://svn.apache.org/viewvc?rev=919949&view=rev
Log:
json startkey, endkey, and key should be decoded before being sent to the query server or
externals

Modified:
    couchdb/trunk/src/couchdb/couch_httpd_external.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_external.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_external.erl?rev=919949&r1=919948&r2=919949&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_external.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_external.erl Sun Mar  7 08:01:59 2010
@@ -77,7 +77,7 @@
         {<<"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) ->
     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,



Mime
View raw message