From a61a76716b30696fd7b4da863a8e63ca9e30e505 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 9 Feb 2021 20:19:43 +0100 Subject: [PATCH] MongoDB: Use ObjectID only if used --- adminer/drivers/mongo.inc.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/adminer/drivers/mongo.inc.php b/adminer/drivers/mongo.inc.php index 6b043933..7dbcf76b 100644 --- a/adminer/drivers/mongo.inc.php +++ b/adminer/drivers/mongo.inc.php @@ -300,10 +300,8 @@ if (isset($_GET["mongo"])) { if (is_array($where)) { foreach ($where as $expression) { list($col, $op, $val) = explode(" ", $expression, 3); - if ($col == "_id") { - $val = str_replace('MongoDB\BSON\ObjectID("', "", $val); - $val = str_replace('")', "", $val); - $class = 'MongoDB\BSON\ObjectID'; + if ($col == "_id" && preg_match('~^(MongoDB\\\\BSON\\\\ObjectID)\("(.+)"\)$~', $val, $match)) { + list(, $class, $val) = $match; $val = new $class($val); } if (!in_array($op, $adminer->operators)) {