Please sign in to comment.
Support escaped "]" in regexp literal character classes (ex: "/[\]/]/")
https://code.google.com/p/esprima/issues/detail?id=442 The RegExp expression parser did not handle the escape sequence "\]" within character classes, or any escape sequence for that matter. Once in a character class, the parser consumed all characters until reaching "]". This diff makes the parser always consider escape sequences, whether it is currently inside of a character class or not. This more closely matches the grammar, which looks like: RegularExpressionChar ::= RegularExpressionNonTerminator but not \ or / or [ RegularExpressionBackslashSequence RegularExpressionClass ... RegularExpressionClassChar ::= RegularExpressionNonTerminator but not ] or \ RegularExpressionBackslashSequence http://es5.github.io/#x7.8.5 That is, the parser can derive RegularExpressionBackslashSequence both inside and outside of character classes. Test plan: Added test case to test.js and loaded it in Chrome 30 and Firefox 25. These browsers produce different results for `new RegExp('[\\]/]').toString()` so the test case dynamically computes that value.
- Loading branch information...