summaryrefslogtreecommitdiff
path: root/src/mongo/db/instance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/instance.cpp')
-rw-r--r--src/mongo/db/instance.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 2daee09b14d..926cdeecdb6 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -777,13 +777,21 @@ namespace mongo {
void checkAndInsert(const char *ns, /*modifies*/BSONObj& js) {
uassert( 10059 , "object to insert too large", js.objsize() <= BSONObjMaxUserSize);
{
- // check no $ modifiers. note we only check top level. (scanning deep would be quite expensive)
BSONObjIterator i( js );
while ( i.more() ) {
BSONElement e = i.next();
- uassert( 13511 , "document to insert can't have $ fields" , e.fieldName()[0] != '$' );
+
+ // check no $ modifiers. note we only check top level.
+ // (scanning deep would be quite expensive)
+ uassert( 13511, "document to insert can't have $ fields", e.fieldName()[0] != '$' );
+
+ // check no regexp for _id (SERVER-9502)
+ if (str::equals(e.fieldName(), "_id")) {
+ uassert(16824, "can't use a regex for _id", e.type() != RegEx);
+ }
}
}
+
theDataFileMgr.insertWithObjMod(ns,
// May be modified in the call to add an _id field.
js,