From 02dd55e08c2328201849cfda51f203a17885368d Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Tue, 23 Nov 2010 16:40:23 +0000 Subject: Merged revision 1038193 from trunk: Seal documents before passing them to map functions (JavaScript view server only). This prevents one map function from modifying a document before it's passed to another map function. Has no effect on array fields for some Spidermonkey versions (see https://bugzilla.mozilla.org/show_bug.cgi?id=449657). Closes COUCHDB-925. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.0.x@1038196 13f79535-47bb-0310-9956-ffa450edef68 --- share/server/util.js | 8 +++++++- share/server/views.js | 13 +------------ 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'share/server') diff --git a/share/server/util.js b/share/server/util.js index 1b57f041..c5e89f3d 100644 --- a/share/server/util.js +++ b/share/server/util.js @@ -96,7 +96,13 @@ var Couch = { }, recursivelySeal : function(obj) { // seal() is broken in current Spidermonkey - seal(obj); + try { + seal(obj); + } catch (x) { + // Sealing of arrays broken in some SpiderMonkey versions. + // https://bugzilla.mozilla.org/show_bug.cgi?id=449657 + return; + } for (var propname in obj) { if (typeof obj[propname] == "object") { arguments.callee(obj[propname]); diff --git a/share/server/views.js b/share/server/views.js index ffe63377..2a15ee56 100644 --- a/share/server/views.js +++ b/share/server/views.js @@ -105,19 +105,8 @@ var Views = (function() { // ] // - /* - Immutable document support temporarily removed. + Couch.recursivelySeal(doc); - Removed because the seal function no longer works on JS 1.8 arrays, - instead returning an error. The sealing is meant to prevent map - functions from modifying the same document that is passed to other map - functions. However, only map functions in the same design document are - run together, so we have a reasonable expectation they can trust each - other. Any map fun that can't be trusted can be placed in its own - design document, and it cannot affect other map functions. - - recursivelySeal(doc); // seal to prevent map functions from changing doc - */ var buf = []; for (var i = 0; i < State.funs.length; i++) { map_results = []; -- cgit v1.2.3