From ac2900a560c2c4288c4d91622cf3fd6db4959819 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Thu, 5 Nov 2009 12:19:51 +0000 Subject: add safety net for code accidents where the document id in a doc delete request got missing accidentally git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@833036 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_db.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/couchdb') diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index f7fd24a8..3e33bd79 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -39,7 +39,14 @@ handle_request(#httpd{path_parts=[DbName|RestParts],method=Method, {'PUT', []} -> create_db_req(Req, DbName); {'DELETE', []} -> - delete_db_req(Req, DbName); + % if we get ?rev=... the user is using a faulty script where the + % document id is empty by accident. Let them recover safely. + case couch_httpd:qs_value(Req, "rev", false) of + false -> delete_db_req(Req, DbName); + _Rev -> throw({bad_request, + "You tried to DELETE a database with a ?=rev parameter. " + ++ "Did mean to DELETE a document instead?"}) + end; {_, []} -> do_db_req(Req, fun db_req/2); {_, [SecondPart|_]} -> -- cgit v1.2.3