diff options
author | Paul Joseph Davis <davisp@apache.org> | 2009-06-18 23:43:40 +0000 |
---|---|---|
committer | Paul Joseph Davis <davisp@apache.org> | 2009-06-18 23:43:40 +0000 |
commit | a86aa967f17c32881e37955975652522b5bda1da (patch) | |
tree | 5eb1ab40a73d7f2760fd1e3c81ba73b304a6b28a | |
parent | 33b7dfe1eb1914aa1f192e05b44892c6e9ffc537 (diff) |
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
-rw-r--r-- | src/couchdb/couch_db.hrl | 1 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 4 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_show.erl | 6 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_view.erl | 27 |
4 files changed, 15 insertions, 23 deletions
diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl index 0d28b2fd..580b91cb 100644 --- a/src/couchdb/couch_db.hrl +++ b/src/couchdb/couch_db.hrl @@ -167,7 +167,6 @@ include_docs = false, stale = false, multi_get = false, - ignore = false, callback = nil }). diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 65f40472..d1d90c63 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -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() -> diff --git a/src/couchdb/couch_httpd_show.erl b/src/couchdb/couch_httpd_show.erl index ef5d41d1..9b65c076 100644 --- a/src/couchdb/couch_httpd_show.erl +++ b/src/couchdb/couch_httpd_show.erl @@ -94,7 +94,7 @@ 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 @@ -102,13 +102,13 @@ send_view_list_response(Lang, ListSrc, ViewName, DesignId, Req, Db, Keys) -> 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; diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl index 8db561ac..0feb2fac 100644 --- a/src/couchdb/couch_httpd_view.erl +++ b/src/couchdb/couch_httpd_view.erl @@ -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{ |