Escape non-printable characters in user output#7831
Merged
aschmahmann merged 5 commits intomasterfrom Jan 14, 2021
Merged
Conversation
Replaces control characters and non-printable characters with escape sequences, in any fields that are printed by the CLI, which could have been user input. Output from `ipfs cat` is unchanged.
065f5c0 to
7193f95
Compare
aschmahmann
approved these changes
Jan 13, 2021
Contributor
aschmahmann
left a comment
There was a problem hiding this comment.
LGTM, left a few small comments it'd be nice to fix up before merging.
core/commands/cmdenv/env.go
Outdated
Comment on lines
+75
to
+76
| // EscNonPrint converts non-printable characters and backslash into Go | ||
| // escape sequences, if the given string contains any. |
Contributor
There was a problem hiding this comment.
WDYT about adding a comment that we're trying to mimic the escape quoting style from https://www.gnu.org/software/coreutils/manual/html_node/Formatting-the-file-names.html?
Contributor
Author
There was a problem hiding this comment.
The link says essentially what the comment here says, so I don't think it adds much, other than it hints that we are doing this for the same reason. Also, I fear that people will misread that and think it means identical content.
Added brief description of purpose.
Contributor
There was a problem hiding this comment.
Fair enough, if/when we add other escaping options we can add more descriptions
This file contains hidden or 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
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.
Replaces control characters and non-printable characters with escape sequences, in any fields that are printed by the CLI, which could have been user input.
Output from
ipfs catis unchanged.