Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Fix function evaluation by newer SpiderMonkey's.
Browse files Browse the repository at this point in the history
Found this error using the Debian package for SM 1.8.5 and have since
had reports of users seeing it as well. The basic error is that some
versions of SpiderMonkey appear to dislike this call to eval:

    eval("function(){}");

The fix is simply to wrap the function source in parenthesis so that
SM is convinced that it knows how to evaluate a function.



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1176666 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
davisp committed Sep 27, 2011
1 parent 7fe255e commit 293ae22
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion share/server/util.js
Expand Up @@ -63,7 +63,11 @@ var Couch = {
},
compileFunction : function(source, ddoc) {
if (!source) throw(["error","not_found","missing function"]);

// Some newer SpiderMonkey's appear to not like evaluating
// an anonymous function at global scope. Simple fix just
// wraps the source with parens so the function object is
// returned correctly.
source = "(" + source + ")";
var evaluate_function_source = function(source, evalFunction, sandbox) {
sandbox = sandbox || {};
if(typeof CoffeeScript === "undefined") {
Expand Down

0 comments on commit 293ae22

Please sign in to comment.