diff options
author | Benety Goh <benety@mongodb.com> | 2017-06-22 11:47:36 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2017-06-22 13:35:50 -0400 |
commit | 630a397d19a935f46ba1d1cbd6a86dc02be7f278 (patch) | |
tree | f74f59027260120920376f7100f2c5a172f1ad44 /src/mongo/shell/mongo.js | |
parent | 4a5b1dcf17f3235f3d60b481387f2bd46017d81f (diff) | |
download | mongo-630a397d19a935f46ba1d1cbd6a86dc02be7f278.tar.gz |
SERVER-29277 disallow non-string db name arguments to Mongo.getDB()
Diffstat (limited to 'src/mongo/shell/mongo.js')
-rw-r--r-- | src/mongo/shell/mongo.js | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js index 796bfdcbf92..aad971d5092 100644 --- a/src/mongo/shell/mongo.js +++ b/src/mongo/shell/mongo.js @@ -108,11 +108,9 @@ Mongo.prototype.getDB = function(name) { ((typeof this.authenticated == 'undefined') || !this.authenticated)) { jsTest.authenticate(this); } - // There is a weird issue where typeof(db._name) !== "string" when the db name - // is created from objects returned from native C++ methods. - // This hack ensures that the db._name is always a string. - if (typeof(name) === "object") { - name = name.toString(); + if (typeof name != 'string') { + throw Error('getDB failed: db name must be a string: (type: ' + (typeof name) + ') ' + + tojson(name)); } return new DB(this, name); }; |