-
Notifications
You must be signed in to change notification settings - Fork 8
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
Escape control characters #456
Merged
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
Update the unix test fixtures to include samples of strings with the control characters: - `<backspace> ('\\b')` - `<carriage return> ('\\r')` - `<escape> ('\\u001B')` - `<control sequence introducer> ('\\u009B')` and how these should be escaped for each supported Unix shell. The tests for `<end of line> ('\\n')` were also updated due to its relates to the carriage return tests. Also, other test cases that include the carriage return character were update according to how it should be escaped. In most cases, these characters should be escaped because they could allow for controller input outside the range of the input. The most prominent example of this is the carriage return, which resets the cursor to the start of the line. The only exception to this is the exact sequence "\n\r" (newline representation on Windows), which will be preserved as it's known safe (even if it can be considered unnecessary on Unix).
Update the Windows test fixtures to include samples of strings with the control characters: - `<backspace> ('\\b')` - `<carriage return> ('\\r')` - `<escape> ('\\u001B')` - `<control sequence introducer> ('\\u009B')` and how these should be escaped for each supported Windows shell. The tests for `<end of line> ('\\n')` were also updated due to its relates to the carriage return tests. Note that for CMD, there's no actual changes in the expected behaviour when it comes to <end of line> and <carriage return> because it is already the case these will always be removed. In most cases, these characters should be escaped because they could allow for controlling input outside the range of the input. The most prominent example of this is the carriage return, which resets the cursor to the start of the line. The only exception to this is the exact sequence "\n\r" (newline representation on Windows), which will be preserved as it's known safe (even if it can be considered unnecessary on Unix).
Update escaping for all Unix and all Windows shells to escape - `<backspace> ('\\b')` - `<carriage return> ('\\r')` - `<escape> ('\\u001B')` - `<control sequence introducer> ('\\u009B')` in all situations with the soul exception of the carriage return character when it appears in exactly as `\n\r` for Bash, Dash, PowerShell, and Zsh (the carriage return character is already always stripped for CMD).
Codecov Report
@@ Coverage Diff @@
## main #456 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 785 794 +9
=========================================
+ Hits 785 794 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Allow control characters in regular expression as this project sometimes require matching control characters (because they need to be escaped or removed from strings when escaping)
ericcornelissen
force-pushed
the
347-control-chars
branch
5 times, most recently
from
October 9, 2022 09:55
fd667c9
to
c8899fc
Compare
ericcornelissen
force-pushed
the
347-control-chars
branch
2 times, most recently
from
October 9, 2022 10:17
a0bb9fc
to
d54f12d
Compare
Update the fuzz normalization for Unix shells and PowerShell in alignment with the changes to the newline substitution in the source code.
ericcornelissen
force-pushed
the
347-control-chars
branch
from
October 9, 2022 10:28
d54f12d
to
09d2427
Compare
Merged
Update the macro title for the test that runs fixutures to account for the newly introduced control characters.
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.
Closes #347
TODO