-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Unescaped command-line arguments for Windows #85832
Conversation
r? @yaahc (rust-highfive has picked a reviewer for you, use r? to override) |
There's an existing unstable feature I went for I think |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I haven't tried this branch; but if I read the diff correctly, You don't have any test cases where escaping would trigger (only when the argument contains |
Also, isn't there a bug where |
I've disabled inner escaping for unquoted arg. I haven't changed escaping logic. I think it's fine — the rules of CommandLineToArgvW that it uses are just very counter-intuitive. |
Try a test case with |
Why'd you go with calling it |
That's because I've noticed that there's |
@kornelski have you tried the test case suggested by @dgrunwald? I'm curious to know if this is an issue. |
☔ The latest upstream changes (presumably #85270) made this pull request unmergeable. Please resolve the merge conflicts. |
12dd7cb
to
f13bc8a
Compare
@yaahc I've added tests cases for the issue raised. They're fine, because escaping rules on Windows don't double the number of backslashes, only number of backslashes before a quote (the syntax is illogical like that by design). |
To recap the default rules, a backslash is treated literally unless they are directly followed by a double quote. When a double quote is encountered the rules are:
For example, the string
These rules are based on the old 80's DOS shell and can't be changed too much due to backwards compatibility. However, some applications do use their own rules, hence the need for |
I misread the code; I missed that the first copy of the Yeah the rules are weird. Fun fact: the interpretation of double double-quotes |
Sounds like everyone is happy with the PR in it's current state ^_^ @bors r+ |
⌛ Testing commit b86d121c3af1d82425074ae8c005fa96b824aa1d with merge 61e56dc608b0077df1cdc469c0eea3e9a72275ce... |
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
I think mingw uses debug output in tests? I've changed debug output to look exactly like before, and rebased. I can't test mingw, because I don't know how to make x.py use it instead of msvc. |
✌️ @kornelski can now approve this pull request |
📌 Commit bc67f6b has been approved by |
☀️ Test successful - checks-actions |
What's the path for stabilizing this feature? The unstable attribute for it doesn't point at a tracking issue. |
@Xaeroxe There haven't been any objections to this feature, so I think you could make a tracking issue and make a PR to stabilize this feature. |
Tracking issue: #92939 |
Some Windows commands, expecially
cmd.exe /c
, have unusual quoting requirements which are incompatible with default rules assumed for.arg()
.This adds
.unquoted_arg()
toCommand
via WindowsCommandExt
trait.Fixes #29494