-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix WildcardPattern.IsMatch to not include backtick in SpecialChars
#24893
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
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
/azp run |
|
Azure Pipelines successfully started running 4 pipeline(s). |
|
@ArmaanMcleod Rethinking related issue I believe right fix could be removing backtick from SpecialChars. I add a comment there. Could you please try this in new PR? |
@iSazonov Could do that but current fix is not breaking behaviour since backtick handled separately in |
|
@ArmaanMcleod Discussion in the issue was too short, did not found root of the issue. I think their assumption about Escape() is wrong. So I would like to see the test results after removing backtick from SpecialChars so that we can investigate further. |
@iSazonov Yep done. Lets see test results and see. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
I see only our updated xUnit test failed. Could you please fix tests. |
@iSazonov Yep will do. I also think it is worth bring back Pester tests and doing E.g. We need a test which validates below works: 'a`b' -like 'a`b'
TrueI think with a change like this the more tests the better to cover all grounds. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
test/powershell/Language/Operators/ComparisonOperator.Tests.ps1
Outdated
Show resolved
Hide resolved
WildcardPattern.Escape to escape backticks correctlyWildcardPattern.IsMatch to not include backtick as special character
WildcardPattern.IsMatch to not include backtick as special characterWildcardPattern.IsMatch to not include backtick in SpecialChars
|
@mklement0 Could you please play with the build and try to find side (break something) effects? |
|
@iSazonov, I haven't really followed the discussion, so I'm hoping @IISResetMe can take a look. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
Forgive me if I'm missing something obvious here, but this change appears to break This behavior: ... is entirely correct, I'm not suggesting we change that at all - having to use the same escape character for both the literal syntax and the pattern is potentially confusing, and I'm sure we can do a better job of explaining it in the docs, but it's entirely expected. Instead of breaking If we make that change instead, then this will start working as expected: |
|
@IISResetMe Thanks! I see
This says that WildcardPattern explicitly process escaping in Pattern. So the PR is not right way. |
|
Thanks @IISResetMe @iSazonov Yeah had the same conclusion and just got confused. I will close this PR since its not the correct fix. We can start again in another PR. Happy for you to take over if you have the right fix in mind. If not i will have a look based on our findings when i have time π |
|
π£ Hey @ArmaanMcleod, how did we do? We would love to hear your feedback with the link below! π£οΈ π https://aka.ms/PSRepoFeedback |
PR Summary
Fixed
WildcardPattern.IsMatchto not include backtick inSpecialChars. Given-likemaps toWildcardPattern.IsMatchit was breaking for comparison with unescaped and escaped comparisons.PR Context
Fixes #16306
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.- [ ] Issue filed:
(which runs in a different PS Host).