svaarala / duktape

Duktape - embeddable Javascript engine with a focus on portability and compact footprint
MIT License
5.95k stars 514 forks source link

RegEx issues #555

Closed JohnMurga closed 8 years ago

JohnMurga commented 8 years ago

In code taken from Mocha and Chai :

var re1 = /^function *\(.*\)\s*{|\(.*\) *=> *{?/
var re2 = /#{this}/g
var re3 = new RegExp("/#{this}/g")
var re4 = new RegExp("/^function *\(.*\)\s*{|\(.*\) *=> *{?/")

Seems to work on V8 and Gecko

On Duktape I get :

SyntaxError: invalid regexp quantifier (unknown char)
fatcerberus commented 8 years ago

This should have been fixed by #513. Try it with the latest master, those regexps should work there.

svaarala commented 8 years ago

@JohnMurga The issue with those RegExps is that they use curly braces as literals without escaping, which is non-standard syntax, the fix would be to escape, e.g.:

/{#this}/g  -->  /\{#this\}/g

But like @fatcerberus said, Duktape master now parses these non-standard regexps because they appear in quite many code bases.

svaarala commented 8 years ago

Closing this as a closed duplicate to #142.