Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FixWildcardPattern.Escape to escape lone backticks correctly#25211

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

ArmaanMcleod
Copy link
Contributor

@ArmaanMcleodArmaanMcleod commentedMar 22, 2025
edited
Loading

PR Summary

FixWildcardPattern.Escape to escape lone backticks correctly.

I have added the-like specific tests in Pester and theEscape() method conversion tests in XUnit.

Given backtick is included inSpecialChars which also has wildcard chars, it seems more straightforward to just doSpecialChars.Contains(ch) instead ofIsWildcardChar(ch) || ch == escapeChar in theEscape() method.

PR Context

Fixes#16306

cc@IISResetMe

PR Checklist

0xfeeddeadbeef reacted with hooray emoji
@iSazonoviSazonov added CL-BreakingChangeIndicates that a PR should be marked as a breaking change in the Change Log CL-GeneralIndicates that a PR should be marked as a general cmdlet change in the Change Log labelsMar 22, 2025
@ArmaanMcleodArmaanMcleod changed the titleFixWildcardPattern.Escape for backticksFixWildcardPattern.Escape to escape lone backticks correctlyMar 22, 2025
@{ lhs = 'abc`def'; operator = '-like'; rhs = [WildcardPattern]::Escape('abc`def'); result = $true }
@{ lhs = 'abc`def'; operator = '-like'; rhs = [WildcardPattern]::Escape('abc``def'); result = $false }
@{ lhs = 'abc``def'; operator = '-like'; rhs = [WildcardPattern]::Escape('abc``def'); result = $true }
@{ lhs = 'abc``def'; operator = '-like'; rhs = [WildcardPattern]::Escape('abc````def'); result = $false }
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is "Win7 backcompatibility requires treating '`' pattern as '' pattern" comment in regex.cs file. Please add a test for the scenario.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@iSazonov Do we need to worry about this? I am not sure why we are still trying to support Win 7 compatibility and why such code even exists 😄. Can you elaborate on what scenario this covers?

Copy link
ContributorAuthor

@ArmaanMcleodArmaanMcleodMar 22, 2025
edited
Loading

Choose a reason for hiding this comment

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

Given also the code changes here are inEscape() I am not sure what I am testing. The Win7 compatibility is more with ensuringWildcardPattern inParse() method treats lone backtick as empty string.

iSazonov and 0xfeeddeadbeef reacted with thumbs up emoji
@iSazonov
Copy link
Collaborator

@IISResetMe Could you please review?

IISResetMe and ArmaanMcleod reacted with thumbs up emoji

@iSazonoviSazonov self-assigned thisMar 22, 2025
@IISResetMe
Copy link
Collaborator

Changes look good to me!

ArmaanMcleod reacted with hooray emoji

@iSazonov

This comment was marked as outdated.

@azure-pipelinesAzure Pipelines

This comment was marked as outdated.

@iSazonoviSazonov merged commite308222 intoPowerShell:masterMar 25, 2025
39 of 41 checks passed
@microsoft-github-policy-serviceMicrosoft GitHub Policy Service
Copy link
Contributor

microsoft-github-policy-servicebot commentedMar 25, 2025
edited by unfurl-linksbot
Loading

📣 Hey@ArmaanMcleod, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗https://aka.ms/PSRepoFeedback

@ArmaanMcleod
Copy link
ContributorAuthor

Amazing. Thanks@iSazonov &@IISResetMe for the reviews and discussion on this one. It took a couple tries but I think we got there in the end 😄. Learnt a lot more how PowerShell does escaping internally too.

IISResetMe reacted with hooray emoji

@iSazonov
Copy link
Collaborator

We are waiting feedback from community now. If there are no critical messages, then this will be included in the new version.

ArmaanMcleod reacted with rocket emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iSazonoviSazonoviSazonov approved these changes

Assignees

@iSazonoviSazonov

Labels
CL-BreakingChangeIndicates that a PR should be marked as a breaking change in the Change LogCL-GeneralIndicates that a PR should be marked as a general cmdlet change in the Change Log
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

WildcardPattern.Escape() does not escape lone backticks correctly
3 participants
@ArmaanMcleod@iSazonov@IISResetMe

[8]ページ先頭

©2009-2025 Movatter.jp