Merge pull request #14150 from michaelnebel/csharp/tracerwhitespace

C#: Explicitly quote arguments in the LUA tracer on windows.
This commit is contained in:
Michael Nebel
2023-09-11 13:18:21 +02:00
committed by GitHub
2 changed files with 4 additions and 9 deletions

View File

@@ -54,7 +54,6 @@ s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test7-db', 'dotne
check_build_out("hello, world", s)
check_diagnostics(test_db="test8-db")
# two arguments, no '--' (first argument quoted)
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test8-db', 'dotnet run "hello world part1" part2'], "test9-db")
check_build_out("hello world part1, part2", s)

View File

@@ -64,7 +64,7 @@ function RegisterExtractorPack(id)
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
-- if an `exe` or `dll` is passed as an argument as the call is forwarded to vstest.
if testMatch and (arg:match('%.exe$') or arg:match('%.dll')) then
if testMatch and (arg:match('%.exe$') or arg:match('%.dll')) then
match = false
break
end
@@ -84,10 +84,6 @@ function RegisterExtractorPack(id)
dotnetRunNeedsSeparator = false
dotnetRunInjectionIndex = i
end
-- if we encounter a whitespace, we explicitly need to quote the argument.
if OperatingSystem == 'windows' and arg:match('%s') then
argv[i] = '"' .. arg .. '"'
end
end
if match then
local injections = { '-p:UseSharedCompilation=false', '-p:EmitCompilerGeneratedFiles=true' }
@@ -114,7 +110,7 @@ function RegisterExtractorPack(id)
invocation = {
path = AbsolutifyExtractorPath(id, compilerPath),
arguments = {
commandLineString = table.concat(argv, " ")
commandLineString = ArgvToCommandLineString(argv)
}
}
}
@@ -178,7 +174,7 @@ function RegisterExtractorPack(id)
seenCompilerCall = true
end
if seenCompilerCall then
table.insert(extractorArgs, '"' .. arg .. '"')
table.insert(extractorArgs, arg)
end
end
@@ -188,7 +184,7 @@ function RegisterExtractorPack(id)
invocation = {
path = AbsolutifyExtractorPath(id, extractor),
arguments = {
commandLineString = table.concat(extractorArgs, " ")
commandLineString = ArgvToCommandLineString(extractorArgs)
}
}
}