[SERVER-5689] The string "return," passed as a parameter to MongoDB function calls, causes Javascript to return Created: 23/Apr/12  Updated: 11/Jul/16  Resolved: 21/Mar/13

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: 1.8.4, 2.0.4
Fix Version/s: 2.5.0

Type: Bug Priority: Major - P3
Reporter: Will Fitzgerald Assignee: Andrew Emil (Inactive)
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

This fails on OsX and Linux.


Attachments: Text File error20_logs.txt    
Backwards Compatibility: Minor Change
Operating System: ALL
Participants:

 Description   

Passing the string "return" to a JavaScript function apparently causes JavaScript to return abnormally. Here is the simplest example I have:

MongoDB shell version: 2.0.4
connecting to: test
> db.system.js.save({_id: "error20", value: function(a) {return a}})
> db.eval("error20(\"test\")")
test
> db.eval("error20(\"return\")")
null

Attached is a file showing the same function working for both node.js and the JavaScript interpreter in Chrome.



 Comments   
Comment by auto [ 21/Mar/13 ]

Author:

{u'date': u'2013-03-13T22:24:07Z', u'name': u'AndrewCEmil', u'email': u'andrew.emil@10gen.com'}

Message: SERVER-5689, fix and associated tests
Branch: master
https://github.com/mongodb/mongo/commit/ec757744090ebeac463fdf2ba6ea5e4c9e27851f

Comment by Ben Becker [ 11/Mar/13 ]

This issue still exists in v2.4.0-rc2.

Generated at Thu Feb 08 03:09:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.