Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 47858 invoked from network); 9 May 2009 19:10:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 May 2009 19:10:25 -0000 Received: (qmail 32601 invoked by uid 500); 9 May 2009 19:10:25 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 32533 invoked by uid 500); 9 May 2009 19:10:25 -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 32524 invoked by uid 99); 9 May 2009 19:10:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 May 2009 19:10:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 May 2009 19:10:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BBB1523889DD; Sat, 9 May 2009 19:10:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r773261 - in /couchdb/branches/0.9.x: ./ etc/default/couchdb share/www/script/test/basics.js src/couchdb/couch_doc.erl Date: Sat, 09 May 2009 19:10:02 -0000 To: commits@couchdb.apache.org From: davisp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090509191002.BBB1523889DD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davisp Date: Sat May 9 19:10:01 2009 New Revision: 773261 URL: http://svn.apache.org/viewvc?rev=773261&view=rev Log: Backporting 773260 from trunk. Fix check for invalid document members. Modified: couchdb/branches/0.9.x/ (props changed) couchdb/branches/0.9.x/etc/default/couchdb (props changed) couchdb/branches/0.9.x/share/www/script/test/basics.js couchdb/branches/0.9.x/src/couchdb/couch_doc.erl Propchange: couchdb/branches/0.9.x/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sat May 9 19:10:01 2009 @@ -1,3 +1,3 @@ /couchdb/branches/design_resources:751716-751803 /couchdb/branches/form:729440-730015 -/couchdb/trunk:758717,760442,760503,760532,760535,760537-760539,761343,761347-761348,761352-761353,761355,762016,765420,765479,766347,766353,766358,766373,766505,767398,767543,768573,769109,769127,769804,770782,771472 +/couchdb/trunk:758717,760442,760503,760532,760535,760537-760539,761343,761347-761348,761352-761353,761355,762016,765420,765479,766347,766353,766358,766373,766505,767398,767543,768573,769109,769127,769804,770782,771472,773260 Propchange: couchdb/branches/0.9.x/etc/default/couchdb ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sat May 9 19:10:01 2009 @@ -1,4 +1,4 @@ /couchdb/branches/design_resources/etc/default/couchdb:751716-751803 /couchdb/branches/form/etc/default/couchdb:729440-730015 -/couchdb/trunk/etc/default/couchdb:758717,760442,760503,760532,760535,760537-760539,761343,761347-761348,761352-761353,761355,762016,765420,765479,766347,766353,766358,766373,766505,767398,767543,768573,769109,769127,769804,770782,771472 +/couchdb/trunk/etc/default/couchdb:758717,760442,760503,760532,760535,760537-760539,761343,761347-761348,761352-761353,761355,762016,765420,765479,766347,766353,766358,766373,766505,767398,767543,768573,769109,769127,769804,770782,771472,773260 /incubator/couchdb/trunk/etc/default/couchdb:642419-694440 Modified: couchdb/branches/0.9.x/share/www/script/test/basics.js URL: http://svn.apache.org/viewvc/couchdb/branches/0.9.x/share/www/script/test/basics.js?rev=773261&r1=773260&r2=773261&view=diff ============================================================================== --- couchdb/branches/0.9.x/share/www/script/test/basics.js (original) +++ couchdb/branches/0.9.x/share/www/script/test/basics.js Sat May 9 19:10:01 2009 @@ -145,4 +145,26 @@ // deleting a non-existent doc should be 404 xhr = CouchDB.request("DELETE", "/test_suite_db/doc-does-not-exist"); T(xhr.status == 404); + + // Check for invalid document members + bad_docs = [ + ["goldfish", {"_zing": 4}], + ["zebrafish", {"_zoom": "hello"}], + ["mudfish", {"zane": "goldfish", "_fan": "something smells delicious"}], + ["tastyfish", {"_bing": {"wha?": "soda can"}}] + ] + var test_doc = function(info) { + var data = JSON.stringify(info[1]); + + xhr = CouchDB.request("PUT", "/test_suite_db/" + info[0], {body: data}); + T(xhr.status == 500); + result = JSON.parse(xhr.responseText); + T(result.error == "doc_validation"); + + xhr = CouchDB.request("POST", "/test_suite_db/", {body: data}); + T(xhr.status == 500); + result = JSON.parse(xhr.responseText); + T(result.error == "doc_validation"); }; + bad_docs.forEach(test_doc); +}; Modified: couchdb/branches/0.9.x/src/couchdb/couch_doc.erl URL: http://svn.apache.org/viewvc/couchdb/branches/0.9.x/src/couchdb/couch_doc.erl?rev=773261&r1=773260&r2=773261&view=diff ============================================================================== --- couchdb/branches/0.9.x/src/couchdb/couch_doc.erl (original) +++ couchdb/branches/0.9.x/src/couchdb/couch_doc.erl Sat May 9 19:10:01 2009 @@ -212,7 +212,7 @@ transfer_fields(Rest, Doc); % unknown special field -transfer_fields([{<<"_",Name/binary>>, Start} | _], _) when is_integer(Start) -> +transfer_fields([{<<"_",Name/binary>>, _} | _], _) -> throw({doc_validation, ?l2b(io_lib:format("Bad special document member: _~s", [Name]))});