syntax-error icon indicating copy to clipboard operation
syntax-error copied to clipboard

various programs with unmatching curlies and parens do not cause SyntaxError to be thrown

Open michaelficarra opened this issue 11 years ago • 2 comments

> require('syntax-error')('})({')
undefined

michaelficarra avatar Aug 12 '14 22:08 michaelficarra

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.

ArtskydJ avatar Jan 27 '16 17:01 ArtskydJ

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.

m1el avatar Jul 06 '18 22:07 m1el