From commits-return-6058-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Sun Mar 13 12:51:26 2011 Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 43406 invoked from network); 13 Mar 2011 12:51:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Mar 2011 12:51:26 -0000 Received: (qmail 35665 invoked by uid 500); 13 Mar 2011 12:51:26 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 35629 invoked by uid 500); 13 Mar 2011 12:51:26 -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 35622 invoked by uid 99); 13 Mar 2011 12:51:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Mar 2011 12:51:26 +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.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Mar 2011 12:51:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D4D6123889E0; Sun, 13 Mar 2011 12:50:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1081104 - /couchdb/branches/1.1.x/src/couchdb/couch_js_functions.hrl Date: Sun, 13 Mar 2011 12:50:57 -0000 To: commits@couchdb.apache.org From: fdmanana@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110313125057.D4D6123889E0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fdmanana Date: Sun Mar 13 12:50:57 2011 New Revision: 1081104 URL: http://svn.apache.org/viewvc?rev=1081104&view=rev Log: Merged revision 1081096 from trunk Replicator database: only validate user_ctx if doc is not being deleted Modified: couchdb/branches/1.1.x/src/couchdb/couch_js_functions.hrl Modified: couchdb/branches/1.1.x/src/couchdb/couch_js_functions.hrl URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_js_functions.hrl?rev=1081104&r1=1081103&r2=1081104&view=diff ============================================================================== --- couchdb/branches/1.1.x/src/couchdb/couch_js_functions.hrl (original) +++ couchdb/branches/1.1.x/src/couchdb/couch_js_functions.hrl Sun Mar 13 12:50:57 2011 @@ -176,38 +176,40 @@ reportError('The `query_params\\' field must be an object.'); } - } - if (newDoc.user_ctx) { - var user_ctx = newDoc.user_ctx; + if (newDoc.user_ctx) { + var user_ctx = newDoc.user_ctx; - if (typeof user_ctx !== 'object') { - reportError('The `user_ctx\\' property must be an object.'); - } + if ((typeof user_ctx !== 'object') || (user_ctx === null)) { + reportError('The `user_ctx\\' property must be a ' + + 'non-null object.'); + } - if (!(user_ctx.name === null || + if (!(user_ctx.name === null || (typeof user_ctx.name === 'undefined') || ((typeof user_ctx.name === 'string') && user_ctx.name.length > 0))) { - reportError('The `user_ctx.name\\' property must be a ' + - 'non-empty string.'); - } - if (user_ctx.roles && !isArray(user_ctx.roles)) { - reportError('The `user_ctx.roles\\' property must be ' + - 'an array of strings.'); - } + reportError('The `user_ctx.name\\' property must be a ' + + 'non-empty string or null.'); + } - if (user_ctx.roles) { - for (var i = 0; i < user_ctx.roles.length; i++) { - var role = user_ctx.roles[i]; + if (user_ctx.roles && !isArray(user_ctx.roles)) { + reportError('The `user_ctx.roles\\' property must be ' + + 'an array of strings.'); + } - if (typeof role !== 'string' || role.length === 0) { - reportError('Each role must be a non-empty string.'); - } - if (role[0] === '_') { - reportError('System roles (starting with underscore) ' + - 'are not allowed.'); + if (user_ctx.roles) { + for (var i = 0; i < user_ctx.roles.length; i++) { + var role = user_ctx.roles[i]; + + if (typeof role !== 'string' || role.length === 0) { + reportError('Roles must be non-empty strings.'); + } + if (role[0] === '_') { + reportError('System roles (starting with an ' + + 'underscore) are not allowed.'); + } } } }