-
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
Preserve whitespace when interpolation: true
(Unix)
#584
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
Example implementation of escaping whitespace, in this case tabs, for Unix shells. In particular when escaping unquoted (and "unprotected", unlike e.g. calling `execFile` with a falsy `shell` value) arguments.
Codecov Report
@@ Coverage Diff @@
## main #584 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 840 843 +3
=========================================
+ Hits 840 843 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
ericcornelissen
commented
Dec 23, 2022
Example implementation of escaping whitespace, in this case spaces, for Unix shells. In particular when escaping unquoted (and "unprotected", unlike e.g. calling `execFile` with a falsy `shell` value) arguments. Since whitespace may change how other things are escaped, to be on the conservative it is now escaped last. To minimize changes `\n` is escaped after `[\t ]` (for now). Fuzzing required some changes as a previous side effect is removed as a result of this change. In particular, spaces (` `) introduced as a result of replacing leading/trailing newlines would be removed due to the trimming logic. This no longer happens due to the source code changes in this commit. This is overcome by using an intermediate representation that's guarenteed not to be in the string (due to line 55). The "Hello world" sample string test case has been removed as it would actually belong in the `"<space> (' ')"` data group. Since this kind of string is already covered it's removed.
ericcornelissen
force-pushed
the
346-escape-perserve-whitespace
branch
from
December 26, 2022 19:05
579937a
to
31746b6
Compare
This comment was marked as resolved.
This comment was marked as resolved.
ericcornelissen
changed the title
Preserve whitespace when
Preserve whitespace when Dec 28, 2022
interpolation: true
interpolation: true
(Unix)
ericcornelissen
commented
Dec 28, 2022
With ` ` and `\t` updated to not split arguments anymore, update escaping for Bash, Dash, and Zsh, to also escape `\n` such that it does not result in argument splitting.
ericcornelissen
commented
Dec 28, 2022
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.
Partially addresses #346
Summary
Add support for preserving whitespace when using
escape(., { interpolation: true })
/escapeAll(., { interpolation: true })
for unquoted and "unprotected"1 arguments on Unix. The result(/goal) should be that escaped arguments are no longer split on whitespace and that the original whitespace character is maintained.Footnotes
unlike protected, e.g. using
escape
withexecFile
. ↩