syntax-error
syntax-error copied to clipboard
various programs with unmatching curlies and parens do not cause SyntaxError to be thrown
> require('syntax-error')('})({')
undefined
Technically, node does allow some weird syntax:
C:\Users\Michael\Github\JS_Source>cat unmatching.js
}, function (){
C:\Users\Michael\Github\JS_Source>node unmatching.js
Although the specific case you mentioned does throw an error for another reason.
Edit in case it's unclear, I do feel like this is an issue, even though node acts funny.
There's also invalid result when providing a crafted program:
let syntaxError = require('syntax-error');
let err = syntaxError('}); function undefined() { return 42; }; ({');
console.log(err(), err.toString());
42 'function undefined() { return 42; }'
As far as I know, on its own it doesn't allow arbitrary code execution, but I might be missing something.