Permalink
Browse files

Fixes COUCHDB-383 - Ignore extra URL parameters.

No one opposed the switch so here it is.



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@786337 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 33b7dfe commit a86aa967f17c32881e37955975652522b5bda1da @davisp davisp committed Jun 18, 2009
Showing with 15 additions and 23 deletions.
  1. +0 −1 src/couchdb/couch_db.hrl
  2. +2 −2 src/couchdb/couch_httpd_db.erl
  3. +3 −3 src/couchdb/couch_httpd_show.erl
  4. +10 −17 src/couchdb/couch_httpd_view.erl
View
@@ -167,7 +167,6 @@
include_docs = false,
stale = false,
multi_get = false,
- ignore = false,
callback = nil
}).
@@ -337,7 +337,7 @@ db_req(#httpd{method='GET',path_parts=[_,<<"_all_docs_by_seq">>]}=Req, Db) ->
limit = Limit,
skip = SkipCount,
direction = Dir
- } = QueryArgs = couch_httpd_view:parse_view_params(Req, nil, map, strict),
+ } = QueryArgs = couch_httpd_view:parse_view_params(Req, nil, map),
{ok, Info} = couch_db:get_db_info(Db),
CurrentEtag = couch_httpd:make_etag(proplists:get_value(update_seq, Info)),
@@ -453,7 +453,7 @@ all_docs_view(Req, Db, Keys) ->
limit = Limit,
skip = SkipCount,
direction = Dir
- } = QueryArgs = couch_httpd_view:parse_view_params(Req, Keys, map, strict),
+ } = QueryArgs = couch_httpd_view:parse_view_params(Req, Keys, map),
{ok, Info} = couch_db:get_db_info(Db),
CurrentEtag = couch_httpd:make_etag(proplists:get_value(update_seq, Info)),
couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
@@ -94,21 +94,21 @@ send_view_list_response(Lang, ListSrc, ViewName, DesignId, Req, Db, Keys) ->
Reduce = couch_httpd_view:get_reduce_type(Req),
case couch_view:get_map_view(Db, DesignId, ViewName, Stale) of
{ok, View, Group} ->
- QueryArgs = couch_httpd_view:parse_view_params(Req, Keys, map, ignore),
+ QueryArgs = couch_httpd_view:parse_view_params(Req, Keys, map),
output_map_list(Req, Lang, ListSrc, View, Group, Db, QueryArgs, Keys);
{not_found, _Reason} ->
case couch_view:get_reduce_view(Db, DesignId, ViewName, Stale) of
{ok, ReduceView, Group} ->
case Reduce of
false ->
QueryArgs = couch_httpd_view:parse_view_params(
- Req, Keys, map_red, ignore
+ Req, Keys, map_red
),
MapView = couch_view:extract_map_view(ReduceView),
output_map_list(Req, Lang, ListSrc, MapView, Group, Db, QueryArgs, Keys);
_ ->
QueryArgs = couch_httpd_view:parse_view_params(
- Req, Keys, reduce, ignore
+ Req, Keys, reduce
),
output_reduce_list(Req, Lang, ListSrc, ReduceView, Group, Db, QueryArgs, Keys)
end;
@@ -15,7 +15,7 @@
-export([handle_view_req/2,handle_temp_view_req/2]).
--export([get_stale_type/1, get_reduce_type/1, parse_view_params/4]).
+-export([get_stale_type/1, get_reduce_type/1, parse_view_params/3]).
-export([make_view_fold_fun/6, finish_view_fold/3, view_row_obj/3]).
-export([view_group_etag/1, view_group_etag/2, make_reduce_fold_funs/5]).
-export([design_doc_view/5]).
@@ -31,18 +31,18 @@ design_doc_view(Req, Db, Id, ViewName, Keys) ->
Reduce = get_reduce_type(Req),
Result = case couch_view:get_map_view(Db, DesignId, ViewName, Stale) of
{ok, View, Group} ->
- QueryArgs = parse_view_params(Req, Keys, map, strict),
+ QueryArgs = parse_view_params(Req, Keys, map),
output_map_view(Req, View, Group, Db, QueryArgs, Keys);
{not_found, Reason} ->
case couch_view:get_reduce_view(Db, DesignId, ViewName, Stale) of
{ok, ReduceView, Group} ->
case Reduce of
false ->
- QueryArgs = parse_view_params(Req, Keys, red_map, strict),
+ QueryArgs = parse_view_params(Req, Keys, red_map),
MapView = couch_view:extract_map_view(ReduceView),
output_map_view(Req, MapView, Group, Db, QueryArgs, Keys);
_ ->
- QueryArgs = parse_view_params(Req, Keys, reduce, strict),
+ QueryArgs = parse_view_params(Req, Keys, reduce),
output_reduce_view(Req, ReduceView, Group, QueryArgs, Keys)
end;
_ ->
@@ -82,12 +82,12 @@ handle_temp_view_req(#httpd{method='POST'}=Req, Db) ->
Keys = proplists:get_value(<<"keys">>, Props, nil),
case proplists:get_value(<<"reduce">>, Props, null) of
null ->
- QueryArgs = parse_view_params(Req, Keys, map, strict),
+ QueryArgs = parse_view_params(Req, Keys, map),
{ok, View, Group} = couch_view:get_temp_map_view(Db, Language,
DesignOptions, MapSrc),
output_map_view(Req, View, Group, Db, QueryArgs, Keys);
RedSrc ->
- QueryArgs = parse_view_params(Req, Keys, reduce, strict),
+ QueryArgs = parse_view_params(Req, Keys, reduce),
{ok, View, Group} = couch_view:get_temp_reduce_view(Db, Language,
DesignOptions, MapSrc, RedSrc),
output_reduce_view(Req, View, Group, QueryArgs, Keys)
@@ -196,7 +196,7 @@ get_stale_type(Req) ->
get_reduce_type(Req) ->
list_to_atom(couch_httpd:qs_value(Req, "reduce", "true")).
-parse_view_params(Req, Keys, ViewType, IgnoreType) ->
+parse_view_params(Req, Keys, ViewType) ->
QueryList = couch_httpd:qs(Req),
QueryParams =
lists:foldl(fun({K, V}, Acc) ->
@@ -208,8 +208,7 @@ parse_view_params(Req, Keys, ViewType, IgnoreType) ->
end,
Args = #view_query_args{
view_type=ViewType,
- multi_get=IsMultiGet,
- ignore=IgnoreType
+ multi_get=IsMultiGet
},
QueryArgs = lists:foldl(fun({K, V}, Args2) ->
validate_view_query(K, V, Args2)
@@ -351,14 +350,8 @@ validate_view_query(include_docs, true, Args) ->
end;
validate_view_query(include_docs, _Value, Args) ->
Args;
-validate_view_query(extra, {Key, _}, Args) ->
- case Args#view_query_args.ignore of
- strict ->
- Msg = io_lib:format("Invalid URL parameter: ~p", [Key]),
- throw({query_parse_error, ?l2b(Msg)});
- _ ->
- Args
- end.
+validate_view_query(extra, _Value, Args) ->
+ Args.
make_view_fold_fun(Req, QueryArgs, Etag, Db, TotalViewCount, HelperFuns) ->
#view_query_args{

0 comments on commit a86aa96

Please sign in to comment.