-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
syscall/exec_windows.go: appendEscapeArg does not escape all necessary characters #68313
Comments
Duplicate of #15566 |
@seankhliao that doesn't sound like the same issue, though it touches on the same mechanic. The issue you linked speaks about arguments that are getting escaped which should not have been, I'm talking about arguments that aren't getting quoted that should have been. Please reopen this bug, as I don't think that a fix for the issue you linked would address the issue I'm raising. |
I believe it's the same, see also #27199 (comment) |
@seankhliao alright, I'll defer to your better judgement. Thanks! |
Go version
go version go1.22.4 windows/amd64
Output of
go env
in your module/workspace:What did you do?
I'm trying to run a go executable with problematic arguments, eg.
Under the hood this will forward the arguments to a file called
test.bat
, and print the arguments.This is what the files look like:
test.go:
test.bat:
What did you see happen?
What did you expect to see?
Through debugging I found that the issue is down to the
appendEscapeArg
function inexec_windows.go
under thesyscall
package. This function will add quotes around arguments that have spaces or tabs, but it doesn't look for any other characters that need escaping.I noticed you can override the commandLine that syscall is served and bypass this function, and so I copied and tweaked the relevant code to also escape arguments that contain
<
, or>
. Now it works as expected.I'd open a PR, but I don't know enough about windows, particularly; are there other characters that need escaping?
Here's my fix for what it's worth:
The above is identical to the native implementation, except that it renames
hasSpace
toneedsQuotes
and adds, '<', '>'
to the needsQuotes switch case.The text was updated successfully, but these errors were encountered: