SERVER-1840 make eval function construction logic in v8 more consistent with sm

This commit is contained in:
Aaron
2010-10-04 14:44:11 -07:00
parent 9d00c0c7e9
commit 92a5d51100
3 changed files with 15 additions and 1 deletions

View File

@@ -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 ) ){