couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Joseph Davis (Commented) (JIRA)" <>
Subject [jira] [Commented] (COUCHDB-1397) Function expressions, evals in SpiderMonkey
Date Thu, 02 Feb 2012 16:38:53 GMT


Paul Joseph Davis commented on COUCHDB-1397:

Describing this as exploiting a bug is incorrect. SpiderMonkey had a non-standard extension
to JavaScript that allowed for this syntax to be considered valid. It was enabled by default.

Recent SpiderMonkey trunk has removed this option so it is no longer an error. The logic underneath
is interesting in that it has to specifically check for this condition (ie, its completely
valid except for a single "is anonymous function as statement" check.

The nicest (and probably least likely) solution would be for SpiderMonkey to add this option
back but just disable it by default. I asked the SM team in IRC shortly after we found the
issue and they expressed a very negative view of this approach so I doubt it's a possibility.

For reference, Jason's example:

{ "views":{"people":{"map": 
      "function(doc) { emit(, 1) }" 

And a fixed example that could work (with modifications to couchjs):

{ "views":{"people":{"map": 
      "function map(doc) { emit(, 1) }" 

and alternatively: 

{ "views":{"people":{"map": 
      "var map = function(doc) { emit(, 1) }" 

We can upgrade couchjs to accept either form quite easily. I think a reasonable plan would
be to have a version of couchjs that accepts both and logs a deprecation warning about the
old version. Then we just need to go on a PR campaign to get everyone to make the upgrade
so they're prepared for when their code eventually needs to run on a newer SpiderMonkey.

Also, I'm not convinced that this needs to be in 1.2. We still have a bit of time to prepare
a 1.2.1 that includes this. 1.2 should've been out a long time ago and I'd rather we focus
on getting that out and then worrying about this afterwards since we have a plausible backwards
compatible upgrade path.

> Function expressions, evals in SpiderMonkey
> -------------------------------------------
>                 Key: COUCHDB-1397
>                 URL:
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.2
>         Environment: All
>            Reporter: Jason Smith
> New SpiderMonkey releases do not eval() a sole anonymous function expression. That is
not a valid JavaScript statement, and so it is not a valid JavaScript script.
> COUCHDB-1302 addressed this for 1.1 and the 1.1.x branch. This ticket is for 1.2. (Sorry
to spam COUCHDB-1302. I saw "Unassigned" and read "Unresolved.")

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message