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
Adding array of special character, and escaping them #125
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This should fix issue #124. Tested using standard (!) prefixes, and indicated issue prefix (.), and other random ones (a) Basically, some characters are regex special characters... '.' is a wildcard... so it was matching on literally everything. Adding an escape character (only when it's needed) allows the match to be literal.
Would using `[regex]::escape()` be easier here so we don't need to maintain that list of special characters? We can just make it `$prefix = [regex]::escape($prefix) ` and that should be all needed.
…________________________________
From: Joshua King <notifications@github.com>
Sent: Thursday, October 11, 2018 1:53:57 AM
To: poshbotio/PoshBot
Cc: Subscribed
Subject: [poshbotio/PoshBot] Adding array of special character, and escaping them (#125)
Description
Adding array of special character, and escaping them
Basically, some characters are regex special characters... '.' is a wildcard... so it was matching on literally everything. Adding an escape character (only when it's needed) allows the match to be literal.
Related Issue
This should fix issue #124<#124>.
Motivation and Context
Allows using desired prefix characters, such as .
. about
How Has This Been Tested?
Tested using standard (!) prefixes, and indicated issue prefix (.), and other random ones (a)
Also tested to ensure that string prefixes (bender) still work
Screenshots (if appropriate):
Testing with ! prefix
[test-]<https://user-images.githubusercontent.com/6955786/46773852-0c30a500-cd5c-11e8-98d5-3efa1ac0671f.PNG>
Testing with . prefix
[test-period]<https://user-images.githubusercontent.com/6955786/46773863-12bf1c80-cd5c-11e8-81bb-8cac370a47ae.PNG>
Types of changes
* Bug fix (non-breaking change which fixes an issue)
* New feature (non-breaking change which adds functionality)
* Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
* My code follows the code style of this project.
* My change requires a change to the documentation.
* I have updated the documentation accordingly.
* I have read the CONTRIBUTING document.
* I have added tests to cover my changes.
* All new and existing tests passed. (erm 45/53 passed, but they all failures seemed to be 'Path' related.)
________________________________
You can view, comment on, or merge this pull request online at:
#125
Commit Summary
* Adding array of special character, and escaping them
File Changes
* M PoshBot/Classes/Bot.ps1<https://github.com/poshbotio/PoshBot/pull/125/files#diff-0> (16)
Patch Links:
* https://github.com/poshbotio/PoshBot/pull/125.patch
* https://github.com/poshbotio/PoshBot/pull/125.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#125>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AQDqFrG1pdhIeyowjmonxiNIx3hkXc2gks5ujpalgaJpZM4XWlPU>.
|
Ooooh, yes. I had originally tried:
But of course that escaped the carrot. I'll give it a shot. |
This reverts commit 107958a.
Thanks for the suggestion @ChrisLGardner, much cleaner!
~~Don't merge, just realised I missed something~~
Sorted.
|
Given it's used to trim the string, an escape character would have caused issues here.
Awesome. Using |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adding array of special character, and escaping them
Basically, some characters are regex special characters... '.' is a wildcard... so it was matching on literally everything. Adding an escape character (only when it's needed) allows the match to be literal.
Related Issue
This should fix issue #124.
Motivation and Context
Allows using desired prefix characters, such as .
. about
How Has This Been Tested?
Tested using standard (!) prefixes, and indicated issue prefix (.), and other random ones (a)
Also tested to ensure that string prefixes (bender) still work
Screenshots (if appropriate):
Testing with ! prefix
Testing with . prefix
Types of changes
Checklist: