Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CommandBuilder: Use more robust quoting #1540

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

Open
Artoria2e5 wants to merge 11 commits into HMCL-dev:main
base: main
Choose a base branch
Loading
from Artoria2e5:patch-5

Conversation

@Artoria2e5
Copy link
Contributor

@Artoria2e5 Artoria2e5 commented Jun 5, 2022
edited
Loading

  • 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\\|<>&*\\" (java string). 这个按老方法 escape 出来是"He\\\o \\"Wor ld\|<>&*\" (raw string),cmd 没记错的话会认为重定向,但是新方法的"He\\o \\""Wor ld\|<>&*\\"不会。另外 cmd 测试起来很烦,内置echo 和外置程序行为不同,上面的测试用例是用 node -e 写了一个小的替换。
  • The shell quote is overcomplicated. The correct way is a lot like PWSH, in that we have a simple single quote.

* 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.
@Artoria2e5 Artoria2e5 marked this pull request as ready for review June 5, 2022 04:16
Copy link
Collaborator

Bash 单引号内不支持任何转义,包括对单引号本身的转义。你需要证明你对 parseBash 的更改是正确的。

Copy link
Contributor Author

Artoria2e5 commented Sep 7, 2022
edited
Loading

Bash 单引号内不支持任何转义,包括对单引号本身的转义。你需要证明你对 parseBash 的更改是正确的。

对,所以把它换成:

  • ' 关闭单引号环境。
  • \' 正常环境转义。
  • ' 打开继续单引号。

可以参考 python shlex.quote,同样的道理,但是用双引号包中间的单引号:https://github.com/python/cpython/blob/3.10/Lib/shlex.py#L334

Copy link
Contributor Author

Artoria2e5 commented Sep 7, 2022
edited
Loading

不愿意 merge upstream,因为名字不如我改得好。<_<

Copy link
Member

burningtnt commented Aug 8, 2023
edited
Loading

@Artoria2e5 冲突了!快来修

Copy link
Contributor Author

xjb 改名!

Copy link
Member

burningtnt commented Aug 8, 2023
edited
Loading

Checkstyle 炸喽 @Artoria2e5
哈哈哈,Java CI 也炸了

Copy link
Contributor Author

到处改名指望手动网页 merge 能找全本来就是扯淡......

zkitefly reacted with eyes emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /