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

TinyMCE: potential fix for code scanning alert: Inefficient regular expression #4491

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sreichel
Copy link
Contributor

Potential fix for https://github.com/OpenMage/magento-lts/security/code-scanning/102

To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. We can achieve this by ensuring that the sub-expression inside the repetition does not have multiple ways to match the same string. Specifically, we can replace (?:\\.|[^']) with a more precise pattern that avoids ambiguity.

In this case, we can use a negative lookahead to ensure that we match any character except a single quote or a backslash followed by any character. This approach eliminates the ambiguity and prevents exponential backtracking.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…pression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions github-actions bot added the JavaScript Relates to js/* label Jan 16, 2025
@sreichel sreichel marked this pull request as ready for review January 16, 2025 06:21
…pression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@sreichel sreichel marked this pull request as draft January 16, 2025 06:32
@sreichel sreichel marked this pull request as ready for review January 16, 2025 07:43
@sreichel sreichel changed the title Potential fix for code scanning alert no. 102: Inefficient regular expression TinyMCE: potential fix for code scanning alert: Inefficient regular expression Jan 16, 2025
@sreichel sreichel added this to the 20.13.0 milestone Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScript Relates to js/* security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant