summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rw-r--r--share/server/main.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/share/server/main.js b/share/server/main.js
index 05615ccd..3c228779 100644
--- a/share/server/main.js
+++ b/share/server/main.js
@@ -74,7 +74,7 @@ while (cmd = eval(readline())) {
// ]
//
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 @@ while (cmd = eval(readline())) {
quit();
}
} catch (exception) {
- print(toJSON(exception));
+ print(toJSON(exception.toString()));
}
}
@@ -170,6 +170,15 @@ function compileFunction(source) {
}
}
+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"};