@@ -46,30 +46,29 @@ def by_where():
4646 post = posts .find_one ({'$where' : 'this.author === "' + author + '"' }) # $ result=BAD
4747 return show_post (post , author )
4848
49-
5049@app .route ('/byFunction' , methods = ['GET' ])
5150def by_function ():
5251 author = request .args ['author' ]
5352 search = {
54- "body" : 'function(author) { return(author === "' + author + '") }' ,
53+ "body" : 'function(author) { return(author === "' + author + '") }' , # $ result=BAD
5554 "args" : [ "$author" ],
5655 "lang" : "js"
5756 }
5857 # Use `" | "a" === "a` as author
5958 # making the query `this.author === "" | "a" === "a"`
6059 # Found by http://127.0.0.1:5000/byFunction?author=%22%20|%20%22a%22%20===%20%22a
61- post = posts .find_one ({'$expr' : {'$function' : search }}) # $ MISING: result=BAD
60+ post = posts .find_one ({'$expr' : {'$function' : search }}) # $ result=BAD
6261 return show_post (post , author )
6362
6463@app .route ('/byFunctionArg' , methods = ['GET' ])
6564def by_function_arg ():
6665 author = request .args ['author' ]
6766 search = {
68- "body" : 'function(author, target) { return(author === target) }' ,
67+ "body" : 'function(author, target) { return(author === target) }' , # $ result=OK
6968 "args" : [ "$author" , author ],
7069 "lang" : "js"
7170 }
72- post = posts .find_one ({'$expr' : {'$function' : search }}) # $ result=OK
71+ post = posts .find_one ({'$expr' : {'$function' : search }}) # $ SPURIOUS: result=BAD
7372 return show_post (post , author )
7473
7574@app .route ('/' , methods = ['GET' ])
0 commit comments