...
BugZero found this defect 5 days ago.
Between 7.0 and 8.0, the behavior of queries containing components like {$documents: {$function: {body: function (arg) {return arg;}, args: [ array: [ /regex with an escaped \/ character/ ] ], land: "js" } } } changed when sent through OpMsgRequest. In 7.0, the \/ is output correctly, but in 8.0, the \/ becomes a / (the escaping backslash is itself escaped). This does not occur in 8.0 without the nesting, e.g. {$documents: {$function: {body: function (arg) {return arg;}, args: [ regex: /regex with an escaped \/ character/ ] ], land: "js" } } } or {$documents: [ { array: [ /regex with an escaped \/ character/ ] } ] } Further investigation reveals that, compared to using mongosh, the received queries differ. The mongosh query sends an escaped two-character \/ substring, whereas the OpMsgRequest query sends a one-character / substring. Fully reproducing this behavior will likely rewrite writing a test or toy program of some sort in 7.0 to send the right kind of query and observing the received query on the other side. Given that $function is deprecated, it's likely that this is not altogether terribly important – or it might even be fixed by SERVER-98936.