Skip to content

Conversation

@priyankarpal
Copy link
Member

Potential fix for https://github.com/reactplay/react-play/security/code-scanning/13

The inefficient regular expression should be rewritten to avoid ambiguity in the repetition. The most problematic part is [0-9]+ inside a repeated group followed by an optional operator. This can be refactored so that each "term" is clearly defined: a sequence of digits, possibly with decimal points, followed by an operator. We can change this to: (?:[0-9]+[-+*/])*[0-9]*, or even better, use a non-greedy form to prevent ambiguity, or ensure the "operator" always follows a number, preventing ambiguous matches. A common pattern for simple calculator expressions is ([0-9]+(\.[0-9]+)?([-+*/][0-9]+(\.[0-9]+)?]*)?), but to minimize disruption and preserve original logic, use /^(?:[0-9]+[-+*/])*[0-9]*$/.

Steps:

  • On line 62 in src/plays/calculator-by-tea/useCalcalulatorByTeaHook.ts, replace /^(?:[0-9]+[-+*/]?)*[0-9]*$/ with /^(?:[0-9]+[-+*/])*[0-9]*$/. This removes the ambiguity by ensuring the operator is always present between numbers, matching sequences like 12+34*56.
  • No imports or new methods are required.

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

…ression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Priyankar Pal  <88102392+priyankarpal@users.noreply.github.com>
@netlify
Copy link

netlify bot commented Oct 6, 2025

Deploy Preview for reactplayio ready!

Name Link
🔨 Latest commit dc910be
🔍 Latest deploy log https://app.netlify.com/projects/reactplayio/deploys/68e402603429650008a7dfdc
😎 Deploy Preview https://deploy-preview-1614--reactplayio.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hey! contributor, thank you for opening a Pull Request 🎉.

@reactplay/maintainers will review your submission soon and give you helpful feedback. If you're interested in continuing your contributions to open source and want to be a part of a welcoming and fantastic community, we invite you to join our ReactPlay Discord Community.
Show your support by starring ⭐ this repository. Thank you and we appreciate your contribution to open source!
Stale Marking : After 30 days of inactivity this issue/PR will be marked as stale issue/PR and it will be closed and locked in 7 days if no further activity occurs.

@priyankarpal priyankarpal marked this pull request as ready for review October 6, 2025 17:54
@priyankarpal priyankarpal merged commit b434421 into main Oct 6, 2025
4 checks passed
@priyankarpal priyankarpal deleted the alert-autofix-013 branch October 6, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants