diff options
author | Randolph Tan <ren@Randolphs-MacBook-Air.local> | 2012-02-29 17:27:49 -0500 |
---|---|---|
committer | Randolph Tan <ren@Randolphs-MacBook-Air.local> | 2012-03-01 10:51:58 -0500 |
commit | caf6045dd9ec2d4e093a2c2790910eb9ca7900a6 (patch) | |
tree | 15b365d277f3dc7a4b209e362ffe8ac7a2f45026 /src/mongo/scripting/v8_db.cpp | |
parent | 06d2438c122d1a20750f2bf3197df735367e22c4 (diff) | |
download | mongo-caf6045dd9ec2d4e093a2c2790910eb9ca7900a6.tar.gz |
SERVER-5020 Mongo shell should check the validity of the db name for use dbname
No automated test for actually using "use" since the shell cannot parse it correctly when "use" is placed inside a function and assert.throws requires you to pass a function to it. Tested ok on SpiderMonkey and V8 by hand.
Diffstat (limited to 'src/mongo/scripting/v8_db.cpp')
-rw-r--r-- | src/mongo/scripting/v8_db.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/scripting/v8_db.cpp b/src/mongo/scripting/v8_db.cpp index d84f2c30265..852792eb0a8 100644 --- a/src/mongo/scripting/v8_db.cpp +++ b/src/mongo/scripting/v8_db.cpp @@ -23,6 +23,7 @@ #include "util/text.h" #include "../client/syncclusterconnection.h" #include "../s/d_logic.h" +#include "../db/namespacestring.h" #include <iostream> using namespace std; @@ -566,6 +567,10 @@ namespace mongo { for ( int i=0; i<args.Length(); i++ ) assert( ! args[i]->IsUndefined() ); + if ( !NamespaceString::validDBName( toSTLString( args[1] ))) { + return v8::ThrowException( v8::String::New( "invalid database name" )); + } + return v8::Undefined(); } |