couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [1/2] git commit: Validate numeric argument to _revs_limit.
Date Sat, 29 Oct 2011 18:22:41 GMT
Updated Branches:
  refs/heads/1.1.x a3bb784e8 -> 62cabfcf2
  refs/heads/1.2.x fe48ad86e -> 5dfe9a111


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/62cabfcf
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/62cabfcf
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/62cabfcf

Branch: refs/heads/1.1.x
Commit: 62cabfcf28985483c26dee6d045c148f5d90c359
Parents: a3bb784
Author: Jan Lehnardt <jan@apache.org>
Authored: Sat Oct 29 20:17:11 2011 +0200
Committer: Jan Lehnardt <jan@apache.org>
Committed: Sat Oct 29 20:20:17 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/62cabfcf/THANKS
----------------------------------------------------------------------
diff --git a/THANKS b/THANKS
index 470c393..58cc144 100644
--- a/THANKS
+++ b/THANKS
@@ -83,5 +83,6 @@ suggesting improvements or submitting changes. Some of these people are:
  * Alexander Shorin <kxepal@gmail.com>
  * Christopher Bonhage <queezey@me.com>
  * Christian Carter <cdcarter@gmail.com>
+ * Lukasz Mielicki <mielicki@gmail.com>
 
 For a list of authors see the `AUTHORS` file.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/62cabfcf/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/62cabfcf/src/couchdb/couch_httpd_db.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 59eeb98..d763d3b 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -431,8 +431,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));


Mime
View raw message