couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r834436 - in /couchdb/trunk: share/www/script/test/attachments.js src/couchdb/couch_httpd_db.erl
Date Tue, 10 Nov 2009 11:40:01 GMT
Author: jan
Date: Tue Nov 10 11:40:01 2009
New Revision: 834436

URL: http://svn.apache.org/viewvc?rev=834436&view=rev
Log:
Add doc id validation when creating a new document with the
standalone attachment API.

Closes COUCHDB-565.

Modified:
    couchdb/trunk/share/www/script/test/attachments.js
    couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/share/www/script/test/attachments.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/attachments.js?rev=834436&r1=834435&r2=834436&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/attachments.js (original)
+++ couchdb/trunk/share/www/script/test/attachments.js Tue Nov 10 11:40:01 2009
@@ -237,4 +237,11 @@
     headers:{"Content-Type":"text/plain;charset=utf-8"}
   });
   TEquals(201, xhr.status, "should send 201 Accepted");
+
+  // implicit doc creation allows creating docs with a reserved id. COUCHDB-565
+  var xhr = CouchDB.request("PUT", "/test_suite_db/_nonexistant/attachment.txt", {
+    headers: {"Content-Type":"text/plain;charset=utf-8"},
+    body: "THIS IS AN ATTACHMENT. BOOYA!"
+  });
+  TEquals(400, xhr.status, "should return error code 400 Bad Request");
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=834436&r1=834435&r2=834436&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Tue Nov 10 11:40:01 2009
@@ -958,6 +958,7 @@
 
     Doc = case extract_header_rev(Req, couch_httpd:qs_value(Req, "rev")) of
         missing_rev -> % make the new doc
+            couch_doc:validate_docid(DocId),
             #doc{id=DocId};
         Rev ->
             case couch_db:open_doc_revs(Db, DocId, [Rev], []) of



Mime
View raw message