JSFiddle - React, Tailwind, and code Playground
JavaScript
function validateQuery(query) {
const quoteSplit = query.split(/(?<=[^\\])"/);
for (let i = 0; i < quoteSplit.length; i++)
if (i % 2 === 0 && quoteSplit[i].match(/\[\??\(/))
return false;
return true;
}
console.log(validateQuery("$..[?(({__proto__:[].constructor}).constructor(\"self.postMessage({action:'bakeComplete',data:{bakeId:1,dish:{type:1,value:''},duration:1,error:false,id:undefined,inputNum:2,progress:1,result:'<iframe/onload=alert(1337)>',type: 'html'}});\")();)]"));