Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: no-misleading-character-class crash on invalid regex (fixes #12169) #12347

Merged
merged 1 commit into from Oct 25, 2019

Conversation

@mdjermanovic
Copy link
Member

mdjermanovic commented Oct 1, 2019

What is the purpose of this pull request? (put an "X" next to item)

[X] Bug fix #12169

Tell us about your environment

  • ESLint Version: 6.4.0
  • Node Version: 10.16.0
  • npm Version: 6.9.0

What parser (default, Babel-ESLint, etc.) are you using?

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
    ecmaVersion: 2015,
  }
};

What did you do? Please include the actual source code causing the issue.

/* eslint no-misleading-character-class: ["error"] */

var r = new RegExp('[Á] [ ');

What did you expect to happen?

Not to crash.

What actually happened? Please include the actual, raw output from ESLint.

SyntaxError: Invalid regular expression: /[Á] [ /: Unterminated character class
    at RegExpValidator.raise ...

What changes did you make? (Give an overview)

try/catch to ignore invalid regular expressions.

Is there anything you'd like reviewers to focus on?

The original issue is about regex literals with @typescript-eslint/parser, but the same applies to the regex constructor with the default parser.

I think it isn't necessary to add a @typescript-eslint/parser test since it's testable with the default?

@eslint eslint bot added the triage label Oct 1, 2019
@mdjermanovic mdjermanovic added accepted bug rule and removed triage labels Oct 1, 2019
Copy link
Member

platinumazure left a comment

LGTM, thanks!

Copy link
Member

kaicataldo left a comment

LGTM, thanks!

@platinumazure platinumazure merged commit 0bffe95 into master Oct 25, 2019
16 checks passed
16 checks passed
Verify Files
Details
Test (ubuntu-latest, 8.x)
Details
Test (ubuntu-latest, 10.x)
Details
Test (ubuntu-latest, 12.x)
Details
Test (windows-latest, 12.x)
Details
Test (macOS-latest, 12.x)
Details
Browser Test
Details
commit-message Commit message follows guidelines
Details
continuous-integration Build #20191001.4 succeeded
Details
continuous-integration (Test on Node.js 10 (Linux)) Test on Node.js 10 (Linux) succeeded
Details
continuous-integration (Test on Node.js 12 (Linux)) Test on Node.js 12 (Linux) succeeded
Details
continuous-integration (Test on Node.js 12 (Windows)) Test on Node.js 12 (Windows) succeeded
Details
continuous-integration (Test on Node.js 12 (macOS)) Test on Node.js 12 (macOS) succeeded
Details
continuous-integration (Test on Node.js 8 (Linux)) Test on Node.js 8 (Linux) succeeded
Details
licence/cla Contributor License Agreement is signed.
Details
release-monitor No patch release is pending
Details
@platinumazure platinumazure deleted the issue12169 branch Oct 25, 2019
@platinumazure

This comment has been minimized.

Copy link
Member

platinumazure commented Oct 25, 2019

Thanks @mdjermanovic for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.