-
Notifications
You must be signed in to change notification settings - Fork 695
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
CommandBuilder: Use more robust quoting #1540
Open
Artoria2e5
wants to merge
11
commits into
HMCL-dev:main
Choose a base branch
from
Artoria2e5:patch-5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
* A while ago I brewed a pretty good quoting thing with unit tests on CMD (https://github.com/Artoria2e5/node/blob/fix!/child-process-args/test/parallel/test-child-process-spawnsync-shell-args.js). Use that. Specifically, the batch language and MSVCRT interprets the whole quoted thing a bit differently and we need to quote for both. An example that I know breaks is `He\\\\o \\"Wor\tld\\|<>&*\\`. * The shell quote is overcomplicated. The correct way is a lot like PWSH, in that we have a simple single quote.
Bash 单引号内不支持任何转义,包括对单引号本身的转义。你需要证明你对 parseBash 的更改是正确的。 |
对,所以把它换成:
可以参考 python shlex.quote,同样的道理,但是用双引号包中间的单引号:https://github.com/python/cpython/blob/3.10/Lib/shlex.py#L334 |
不愿意 merge upstream,因为名字不如我改得好。<_< |
@Artoria2e5 冲突了!快来修 |
xjb 改名! |
Checkstyle 炸喽 @Artoria2e5 |
到处改名指望手动网页 merge 能找全本来就是扯淡…… |
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.
"He\\\\o \\\"Wor\tld\\|<>&*\\"
(java string). 这个按老方法 escape 出来是"He\\\o \\"Wor ld\|<>&*\"
(raw string),cmd 没记错的话会认为重定向,但是新方法的"He\\o \\""Wor ld\|<>&*\\"
不会。另外 cmd 测试起来很烦,内置echo
和外置程序行为不同,上面的测试用例是用node -e
写了一个小的替换。