Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC6EF96E6 for ; Sat, 29 Oct 2011 18:22:52 +0000 (UTC) Received: (qmail 31661 invoked by uid 500); 29 Oct 2011 18:22:52 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 31633 invoked by uid 500); 29 Oct 2011 18:22:52 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 31626 invoked by uid 99); 29 Oct 2011 18:22:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Oct 2011 18:22:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.114] (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Oct 2011 18:22:51 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2773054730; Sat, 29 Oct 2011 18:22:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jan@apache.org To: commits@couchdb.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: Validate numeric argument to _revs_limit. Message-Id: <20111029182231.2773054730@tyr.zones.apache.org> Date: Sat, 29 Oct 2011 18:22:31 +0000 (UTC) Updated Branches: refs/heads/master cc486419b -> 3b37d17d1 Validate numeric argument to _revs_limit. Closes COUCHDB-1087 Patch by Lukasz Mielicki. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/3b37d17d Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/3b37d17d Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/3b37d17d Branch: refs/heads/master Commit: 3b37d17d1329dbb7515b05a849bfa6131ba1c89b Parents: cc48641 Author: Jan Lehnardt Authored: Sat Oct 29 20:17:11 2011 +0200 Committer: Jan Lehnardt Committed: Sat Oct 29 20:21:48 2011 +0200 ---------------------------------------------------------------------- THANKS | 1 + share/www/script/test/rev_stemming.js | 8 ++++++++ src/couchdb/couch_httpd_db.erl | 9 +++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/3b37d17d/THANKS ---------------------------------------------------------------------- diff --git a/THANKS b/THANKS index 5b1a03c..320d744 100644 --- a/THANKS +++ b/THANKS @@ -89,5 +89,6 @@ suggesting improvements or submitting changes. Some of these people are: * Alexander Shorin * Christopher Bonhage * Christian Carter + * Lukasz Mielicki For a list of authors see the `AUTHORS` file. http://git-wip-us.apache.org/repos/asf/couchdb/blob/3b37d17d/share/www/script/test/rev_stemming.js ---------------------------------------------------------------------- diff --git a/share/www/script/test/rev_stemming.js b/share/www/script/test/rev_stemming.js index 03d91c2..3e36f96 100644 --- a/share/www/script/test/rev_stemming.js +++ b/share/www/script/test/rev_stemming.js @@ -23,6 +23,14 @@ couchTests.rev_stemming = function(debug) { T(db.getDbProperty("_revs_limit") == 1000); + // Make an invalid request to _revs_limit + // Should return 400 + var xhr = CouchDB.request("PUT", "/test_suite_db/_revs_limit", {body:"\"foo\""}); + T(xhr.status == 400); + var result = JSON.parse(xhr.responseText); + T(result.error == "bad_request"); + T(result.reason == "Rev limit has to be an integer"); + var doc = {_id:"foo",foo:0} for( var i=0; i < newLimit + 1; i++) { doc.foo++; http://git-wip-us.apache.org/repos/asf/couchdb/blob/3b37d17d/src/couchdb/couch_httpd_db.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 90ca33a..3d2d2c1 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -422,8 +422,13 @@ db_req(#httpd{path_parts=[_,<<"_security">>]}=Req, _Db) -> db_req(#httpd{method='PUT',path_parts=[_,<<"_revs_limit">>]}=Req, Db) -> Limit = couch_httpd:json_body(Req), - ok = couch_db:set_revs_limit(Db, Limit), - send_json(Req, {[{<<"ok">>, true}]}); + case is_integer(Limit) of + true -> + ok = couch_db:set_revs_limit(Db, Limit), + send_json(Req, {[{<<"ok">>, true}]}); + false -> + throw({bad_request, <<"Rev limit has to be an integer">>}) + end; db_req(#httpd{method='GET',path_parts=[_,<<"_revs_limit">>]}=Req, Db) -> send_json(Req, couch_db:get_revs_limit(Db));