Fix non ES5 compliant regexp #577

Merged
merged 1 commit into from Dec 23, 2015

Projects

None yet

2 participants

@zetaben
Contributor
zetaben commented Dec 23, 2015

ES5 appears to require that { be escaped when not used as part of a quantifier. While this works fine in browsers, it appears to choke less lenient runtimes (e.g. Duktape).

A similar case is discussed in Duktape (svaarala/duktape#69 and svaarala/duktape#74).

Please find attached a simple Duktape-powered C file that tries to parse the given argument file.
test.c.zip

Compile and run using:

$  gcc -std=c99 -o test test.c duktape-1.3.1/src/duktape.c -I duktape-1.3.1/src/  -lm && ./test chai/chai.js

When choking it produces a:
eval failed: SyntaxError: invalid regexp quantifier (unknown char) (line 4401)
when the parsing is fine it will produce :
result is: undefined

@zetaben zetaben Fix non ES5 compliant regexp
ES5 appears to require that { be escaped when not used as part of a quantifier. While this works fine in browsers it appears to choke less lenient runtimes (e.g. Duktape).
37e9d25
@keithamus
Member

Good catch @zetaben. Normally I'd ask for some tests but I'm not exactly how you could test this one without adding something like Duktape to our test suite!

@keithamus keithamus merged commit 067074d into chaijs:master Dec 23, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@zetaben
Contributor
zetaben commented Dec 24, 2015

Thanks @keithamus !

As for tests, I was also not sure of what could be done, maybe a script that depend on execjs (https://github.com/rails/execjs) or duktape.rb (https://github.com/judofyr/duktape.rb) could be launched by your travis ? It would enable to check correct parsing under a few JS runtime without directly depending on them in the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment