Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SERVER-1840 make eval function construction logic in v8 more consiste…

…nt with sm
  • Loading branch information...
commit 92a5d51100a5b45d06ffafe38af7de43e6502915 1 parent 9d00c0c
@astaple astaple authored
View
5 jstests/evale.js
@@ -0,0 +1,5 @@
+t = db.jstests_evale;
+t.drop();
+
+db.eval( function() { return db.jstests_evale.count( { $where:function() { return true; } } ) } );
+db.eval( "db.jstests_evale.count( { $where:function() { return true; } } )" );
View
2  mongo.xcodeproj/project.pbxproj
@@ -69,6 +69,7 @@
932D855211AB912B002749FB /* find7.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = find7.js; sourceTree = "<group>"; };
932D855311AB912B002749FB /* fm4.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = fm4.js; sourceTree = "<group>"; };
932D855411AB912B002749FB /* geo_box1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = geo_box1.js; sourceTree = "<group>"; };
+ 93386F98125A7BB4005E0172 /* evale.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = evale.js; sourceTree = "<group>"; };
933A4D130F55A68600145C4B /* authTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = authTest.cpp; sourceTree = "<group>"; };
933A4D150F55A68600145C4B /* clientTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clientTest.cpp; sourceTree = "<group>"; };
933A4D170F55A68600145C4B /* first.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = first.cpp; sourceTree = "<group>"; };
@@ -841,6 +842,7 @@
934BEB9A10DFFA9600178102 /* jstests */ = {
isa = PBXGroup;
children = (
+ 93386F98125A7BB4005E0172 /* evale.js */,
936D5EC71251BA2A0015722C /* rename4.js */,
93B771FE124024A4007C8F0C /* evald.js */,
93B77135123F0BB2007C8F0C /* indexk.js */,
View
9 scripting/engine_v8.cpp
@@ -250,10 +250,17 @@ namespace mongo {
// --- functions -----
+ bool hasFunctionIdentifier( const string& code ){
+ if ( code.size() < 9 || code.find( "function" ) != 0 )
+ return false;
+
+ return code[8] == ' ' || code[8] == '(';
+ }
+
Local< v8::Function > V8Scope::__createFunction( const char * raw ){
for(; isspace( *raw ); ++raw ); // skip whitespace
string code = raw;
- if ( code.find( "function" ) == string::npos ){
+ if ( !hasFunctionIdentifier( code ) ) {
if ( code.find( "\n" ) == string::npos &&
! hasJSReturn( code ) &&
( code.find( ";" ) == string::npos || code.find( ";" ) == code.size() - 1 ) ){
Please sign in to comment.
Something went wrong with that request. Please try again.