couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r670720 - /incubator/couchdb/trunk/share/server/main.js
Date Mon, 23 Jun 2008 19:51:05 GMT
Author: cmlenz
Date: Mon Jun 23 12:51:05 2008
New Revision: 670720

URL: http://svn.apache.org/viewvc?rev=670720&view=rev
Log:
Follow-up to r670653: Implement deep sealing in Javascript as using the native `JS_SealObject`
function in deep mode somehow also locked down outer scopes, leading to various obscure errors.

Modified:
    incubator/couchdb/trunk/share/server/main.js

Modified: incubator/couchdb/trunk/share/server/main.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/server/main.js?rev=670720&r1=670719&r2=670720&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/server/main.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/server/main.js [utf-8] Mon Jun 23 12:51:05 2008
@@ -74,7 +74,7 @@
         // ]
         //
         var doc = cmd[1];
-        seal(doc, true); // seal to prevent map functions from changing doc
+        recursivelySeal(doc); // seal to prevent map functions from changing doc
         var buf = [];
         for (var i = 0; i < funs.length; i++) {
           map_results = [];
@@ -150,7 +150,7 @@
         quit();
     }
   } catch (exception) {
-    print(toJSON(exception));
+    print(toJSON(exception.toString()));
   }
 }
 
@@ -170,6 +170,15 @@
   }
 }
 
+function recursivelySeal(obj) {
+  seal(obj);
+  for (var propname in obj) {
+    if (typeof doc[propname] == "object") {
+      recursivelySeal(doc[propname]);
+    }
+  }
+}
+
 function toJSON(val) {
   if (typeof(val) == "undefined") {
     throw {error:"bad_value", reason:"Cannot encode 'undefined' value as JSON"};



Mime
View raw message