Skip to content
Snippets Groups Projects
  • Daniel Di Sarli's avatar
    70ce2ba0
    Fix crash with minified functions · 70ce2ba0
    Daniel Di Sarli authored
    This is an example of a valid minified function that doesn't work with the regex in toFunction:
    
        function profileModelWorkerRunner(){var Moment=eval("require")("moment-timezone");self.onmessage=function(event){var profileModelClass=eval("require")(event.data.profileModelPath).default,profileModelWorker=new profileModelClass(Moment,event.data.timezone),params=event.data.params;var result=profileModelWorker.check(params);postMessage(result)}}
    
    I've replaced that code with an eval, which is safer than parsing JS code (which is not a context-free grammar) with regular expressions.
    70ce2ba0
    History
    Fix crash with minified functions
    Daniel Di Sarli authored
    This is an example of a valid minified function that doesn't work with the regex in toFunction:
    
        function profileModelWorkerRunner(){var Moment=eval("require")("moment-timezone");self.onmessage=function(event){var profileModelClass=eval("require")(event.data.profileModelPath).default,profileModelWorker=new profileModelClass(Moment,event.data.timezone),params=event.data.params;var result=profileModelWorker.check(params);postMessage(result)}}
    
    I've replaced that code with an eval, which is safer than parsing JS code (which is not a context-free grammar) with regular expressions.