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

Update inefficient RegEx #357 #494

Merged
merged 1 commit into from
Feb 2, 2024
Merged

Conversation

fajar-apri-alaska
Copy link
Contributor

@fajar-apri-alaska fajar-apri-alaska commented Jan 30, 2024

Alaska Airlines Pull Request

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Resolves: #357

Summary:

  • Update below regex to make it more efficient:
    \r\n|\r|\n -> \r?\n|\r(?!\n)
  1. The \r\n is redundant to \r checking in current pattern, and I think we can combine it with the \n checking by using \r?\n
  2. At first, I want to also remove the standalone \r because it only for older Mac OS, but I think we should keep it for backward compatibility, so adding | \r to the pattern.
  3. Additional (?!\n) in the end is to make sure the \r is not followed by \n, to avoid exponential backtracking on strings starting with ''' and containing many repetitions of '\r\n'. (per latest CodeQL analysis alert https://github.com/AlaskaAirlines/WC-Generator/security/code-scanning/3)

Type of change:

Please delete options that are not relevant.

  • New capability
  • Revision of an existing capability
  • Infrastructure change (automation, etc.)
  • Other (please elaborate)

Checklist:

  • My update follows the CONTRIBUTING guidelines of this project
  • I have performed a self-review of my own update

By submitting this Pull Request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Pull Requests will be evaluated by their quality of update and whether it is consistent with the goals and values of this project. Any submission is to be considered a conversation between the submitter and the maintainers of this project and may require changes to your submission.

Thank you for your submission!

-- Auro Design System Team

@fajar-apri-alaska fajar-apri-alaska requested a review from a team as a code owner January 30, 2024 09:01
@fajar-apri-alaska fajar-apri-alaska self-assigned this Jan 30, 2024
@fajar-apri-alaska fajar-apri-alaska force-pushed the fajarapri/inefficientRegex branch from 2ed4729 to 7848202 Compare January 30, 2024 10:14
- Update below regex to make it more efficient:
\r\n|\r|\n -> \r?\n|\r(?!\n)

1. The \r\n is redundant to \r checking in current pattern,
and I think we can combine it with the \n checking by using \r?\n
2. At first, I want to also remove the standalone \r because it only for older Mac OS,
but I think we should keep it for backward compatibility, so adding | \r to the pattern.
3. Additional (?!\n) in the end is to make sure the \r is not followed by \n,
to avoid exponential backtracking on strings starting with '''
and containing many repetitions of '\r\n'. (per latest [CodeQL analysis alert](https://github.com/AlaskaAirlines/WC-Generator/security/code-scanning/3))

Changes to be committed:
	modified:   package-lock.json
	modified:   template/scripts/generateDocs.mjs
@fajar-apri-alaska fajar-apri-alaska force-pushed the fajarapri/inefficientRegex branch from 7848202 to ce69d1e Compare January 30, 2024 12:17
@blackfalcon blackfalcon merged commit 8e24c16 into master Feb 2, 2024
6 checks passed
@blackfalcon blackfalcon deleted the fajarapri/inefficientRegex branch February 2, 2024 18:26
@blackfalcon
Copy link
Member

🎉 This PR is included in version 4.4.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

@blackfalcon blackfalcon added the released Completed work has been released label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Completed work has been released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants