Skip to content

fix: potential quadratic runtime in regular expression #240

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

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

ericcornelissen
Copy link
Contributor

@ericcornelissen ericcornelissen commented Jul 14, 2025

Prerequisites checklist

What is the purpose of this pull request?

Improve regular expressions in this repository that could match with unexpected overhead for certain strings.

What changes did you make? (Give an overview)

I improved a regular expression in the plugin-kit package that could match in quadratic runtime for certain strings. I did not find any other regular expressions in the source code of this repository that could have this kind of impact.

Related Issues

n/a

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

no

@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jul 14, 2025
@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Jul 14, 2025
@fasttime fasttime moved this from Needs Triage to Triaging in Triage Jul 15, 2025
@fasttime
Copy link
Member

Thanks for the pull request @ericcornelissen. Could you also add a unit test to packages/plugin-kit/tests/config-comment-parser.test.js to show that the problem has been fixed? Mocha tests timeout with an error after 2 seconds, so in this case it's sufficient to no copy-paste the repro code into a new test to verify that no timeout occurs.

@fasttime fasttime moved this from Triaging to Implementing in Triage Jul 15, 2025
Improve a regular expression in the plugin-kit package that could lead
match in quadratic runtime for certain strings.
@ericcornelissen
Copy link
Contributor Author

Updated, without the patch this test takes ~10s for me and therefor fails due to the 2s timeout (unfortunately because it's blocking the test is not killed after 2s).

Copy link
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@fasttime fasttime merged commit b283f64 into eslint:main Jul 16, 2025
21 checks passed
@github-project-automation github-project-automation bot moved this from Implementing to Complete in Triage Jul 16, 2025
@github-actions github-actions bot mentioned this pull request Jul 16, 2025
@ericcornelissen ericcornelissen deleted the patch-1 branch July 16, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug Something isn't working contributor pool
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

2 participants