mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Disallow EJSON custom types as replacement documents in updates
This commit is contained in:
@@ -320,7 +320,7 @@ MongoConnection.prototype._insert = function (collection_name, document,
|
|||||||
if (!(LocalCollection._isPlainObject(document) &&
|
if (!(LocalCollection._isPlainObject(document) &&
|
||||||
!EJSON._isCustomType(document))) {
|
!EJSON._isCustomType(document))) {
|
||||||
sendError(new Error(
|
sendError(new Error(
|
||||||
"Only documents (plain objects) may be inserted into MongoDB"));
|
"Only plain objects may be inserted into MongoDB"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,6 +432,14 @@ MongoConnection.prototype._update = function (collection_name, selector, mod,
|
|||||||
if (!mod || typeof mod !== 'object')
|
if (!mod || typeof mod !== 'object')
|
||||||
throw new Error("Invalid modifier. Modifier must be an object.");
|
throw new Error("Invalid modifier. Modifier must be an object.");
|
||||||
|
|
||||||
|
if (!(LocalCollection._isPlainObject(mod) &&
|
||||||
|
!EJSON._isCustomType(mod))) {
|
||||||
|
throw new Error(
|
||||||
|
"Only plain objects may be used as replacement" +
|
||||||
|
" documents in MongoDB");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
|
|
||||||
var write = self._maybeBeginWrite();
|
var write = self._maybeBeginWrite();
|
||||||
|
|||||||
@@ -1481,6 +1481,7 @@ testAsyncMulti('mongo-livedata - document with a custom type, ' + idGeneration,
|
|||||||
test.isFalse(err);
|
test.isFalse(err);
|
||||||
test.isTrue(id);
|
test.isTrue(id);
|
||||||
docId = id;
|
docId = id;
|
||||||
|
self.docId = docId;
|
||||||
var cursor = self.coll.find();
|
var cursor = self.coll.find();
|
||||||
test.equal(cursor.count(), 1);
|
test.equal(cursor.count(), 1);
|
||||||
var inColl = self.coll.findOne();
|
var inColl = self.coll.findOne();
|
||||||
@@ -1493,6 +1494,12 @@ testAsyncMulti('mongo-livedata - document with a custom type, ' + idGeneration,
|
|||||||
test.isTrue(err);
|
test.isTrue(err);
|
||||||
test.isFalse(id);
|
test.isFalse(id);
|
||||||
}));
|
}));
|
||||||
|
}, function (test, expect) {
|
||||||
|
var self = this;
|
||||||
|
self.coll.update(
|
||||||
|
self.docId, new Dog("rover", "orange"), expect(function (err) {
|
||||||
|
test.isTrue(err);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user