Skip to content

Convert PowerShell escaping to support linear regexp engine#2436

Merged
ericcornelissen merged 17 commits intomainfrom
lregexp-powershell
Apr 4, 2026
Merged

Convert PowerShell escaping to support linear regexp engine#2436
ericcornelissen merged 17 commits intomainfrom
lregexp-powershell

Conversation

@ericcornelissen
Copy link
Copy Markdown
Owner

@ericcornelissen ericcornelissen commented Mar 25, 2026

Relates to #2122

Straightforward translation from RegExp to lRegExp compatible regular
expression using existing techniques (either one-to-one or replacing
lookbehind by capturing groups that are put back into the result when
replacing).
@ericcornelissen ericcornelissen added the refactor Changes existing code without changing functionality label Mar 25, 2026
Expand test fixtures for PowerShell escaping based on mutation testing
results. This mostly identified gaps in the testing where the use of the
"g" flag wasn't covered by tests due to a lack of repeated characters to
escape in a string.

Additionally, based on mutation testing too, update some of the regular
expressions. Expressions anchored to the start or end of the string
don't need to have the "g" flag and the `backslashSuffix` regex can't
possibly match the start of the string because it requires at least a
non-whitespace character at the start and a whitespace character after
that (because of the guard in which this expression is used).
@github-actions github-actions bot added the test Relates to testing label Mar 25, 2026
@ericcornelissen ericcornelissen changed the title Refactor PowerShell argument escaping to use lRegExp Convert PowerShell escaping to support linear regexp engine Mar 25, 2026
@github-actions github-actions bot added the meta Relates to the project or repository itself label Apr 3, 2026
As identified by differential testing (see [1]), this fixes escaping of
double quoting. In particular for cases like `"\\"` in which the first
`"` prevented the regular expression from matching the second `"` due to
the first capturing group in `backslashQuote`. This is fixed using the
marker technique introduced in [2]. To prevent regressions various unit
test fixtures for this and similar cases were added.

[1]: cc1076d
[2]: 0f38a42
@ericcornelissen ericcornelissen marked this pull request as ready for review April 4, 2026 18:38
@ericcornelissen

This comment was marked as resolved.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ericcornelissen

This comment was marked as resolved.

@coderabbitai

This comment has been minimized.

@coderabbitai

This comment has been minimized.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/fixtures/win.js (1)

2991-3024: ⚠️ Potential issue | 🟡 Minor

Cover the whitespace + backslashes + " intersection too.

These additions pin whitespace+quotes and backslashes+quotes separately, but src/internal/win/powershell.js Lines 39-47 and Lines 76-82 change behavior specifically when all three appear in the same argument. That leaves the marker-based branch only partially covered.

Also applies to: 5297-5330


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 757ae6b8-6e04-4704-bb5a-8a2ccfd7d48b

📥 Commits

Reviewing files that changed from the base of the PR and between 3541df1 and ca1ba5e.

📒 Files selected for processing (3)
  • config/eslint.js
  • src/internal/win/powershell.js
  • test/fixtures/win.js

@ericcornelissen ericcornelissen merged commit 94136d5 into main Apr 4, 2026
42 checks passed
@ericcornelissen ericcornelissen deleted the lregexp-powershell branch April 4, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Relates to the project or repository itself refactor Changes existing code without changing functionality test Relates to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant