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

Adding array of special character, and escaping them #125

Merged
merged 4 commits into from Oct 11, 2018
Merged

Adding array of special character, and escaping them #125

merged 4 commits into from Oct 11, 2018

Conversation

Windos
Copy link
Contributor

@Windos Windos commented Oct 11, 2018

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

test-

Testing with . prefix

test-period

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.)

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.
@ChrisLGardner
Copy link

ChrisLGardner commented Oct 11, 2018 via email

@Windos
Copy link
Contributor Author

Windos commented Oct 11, 2018

Ooooh, yes. I had originally tried:

if ($parsedCommand.command -match [regex]::escape("^$prefix")) {

But of course that escaped the carrot. I'll give it a shot.

@Windos
Copy link
Contributor Author

Windos commented Oct 11, 2018 via email

Given it's used to trim the string, an escape character would have caused issues here.
@devblackops devblackops self-assigned this Oct 11, 2018
@devblackops
Copy link
Member

Awesome. Using [regex]::escape() is nice and clean!

@devblackops devblackops merged commit 92e8742 into poshbotio:master Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants