Skip to content

Commit aaaf6f8

Browse files
authored
Merge pull request github#14150 from michaelnebel/csharp/tracerwhitespace
C#: Explicitly quote arguments in the LUA tracer on windows.
2 parents 1b90216 + d4a1c29 commit aaaf6f8

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

csharp/ql/integration-tests/all-platforms/dotnet_run/test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def check_build_out(msg, s):
5454
check_build_out("hello, world", s)
5555
check_diagnostics(test_db="test8-db")
5656

57-
5857
# two arguments, no '--' (first argument quoted)
5958
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test8-db', 'dotnet run "hello world part1" part2'], "test9-db")
6059
check_build_out("hello world part1, part2", s)

csharp/tools/tracing-config.lua

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function RegisterExtractorPack(id)
6464

6565
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
6666
-- if an `exe` or `dll` is passed as an argument as the call is forwarded to vstest.
67-
if testMatch and (arg:match('%.exe$') or arg:match('%.dll')) then
67+
if testMatch and (arg:match('%.exe$') or arg:match('%.dll')) then
6868
match = false
6969
break
7070
end
@@ -84,10 +84,6 @@ function RegisterExtractorPack(id)
8484
dotnetRunNeedsSeparator = false
8585
dotnetRunInjectionIndex = i
8686
end
87-
-- if we encounter a whitespace, we explicitly need to quote the argument.
88-
if OperatingSystem == 'windows' and arg:match('%s') then
89-
argv[i] = '"' .. arg .. '"'
90-
end
9187
end
9288
if match then
9389
local injections = { '-p:UseSharedCompilation=false', '-p:EmitCompilerGeneratedFiles=true' }
@@ -114,7 +110,7 @@ function RegisterExtractorPack(id)
114110
invocation = {
115111
path = AbsolutifyExtractorPath(id, compilerPath),
116112
arguments = {
117-
commandLineString = table.concat(argv, " ")
113+
commandLineString = ArgvToCommandLineString(argv)
118114
}
119115
}
120116
}
@@ -178,7 +174,7 @@ function RegisterExtractorPack(id)
178174
seenCompilerCall = true
179175
end
180176
if seenCompilerCall then
181-
table.insert(extractorArgs, '"' .. arg .. '"')
177+
table.insert(extractorArgs, arg)
182178
end
183179
end
184180

@@ -188,7 +184,7 @@ function RegisterExtractorPack(id)
188184
invocation = {
189185
path = AbsolutifyExtractorPath(id, extractor),
190186
arguments = {
191-
commandLineString = table.concat(extractorArgs, " ")
187+
commandLineString = ArgvToCommandLineString(extractorArgs)
192188
}
193189
}
194190
}

0 commit comments

Comments
 (0)