Skip to content

Commit 27c1900

Browse files
committed
C#: Handle the places where we could risk that Path.Combine would have thrown away the first argument.
1 parent b2addbf commit 27c1900

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

csharp/autobuilder/Semmle.Autobuild.Shared/Project.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public Project(Autobuilder<TAutobuildOptions> builder, string path) : base(build
108108
}
109109

110110
var includePath = builder.Actions.PathJoin(include.Value.Split('\\', StringSplitOptions.RemoveEmptyEntries));
111-
ret.Add(new Project<TAutobuildOptions>(builder, builder.Actions.PathJoin(DirectoryName, includePath)));
111+
var path = Path.IsPathRooted(includePath) ? includePath : builder.Actions.PathJoin(DirectoryName, includePath);
112+
ret.Add(new Project<TAutobuildOptions>(builder, path));
112113
}
113114
return ret;
114115
});

csharp/extractor/Semmle.Extraction.CSharp/Extractor/CsProjFile.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ private static (string[] csFiles, string[] references, string[] projectReference
159159
return null;
160160
}
161161

162-
return Path.GetFullPath(Path.Join(projDir?.FullName ?? string.Empty, Path.DirectorySeparatorChar == '/' ? file.Replace("\\", "/") : file));
162+
var normalized = Path.DirectorySeparatorChar == '/' ? file.Replace("\\", "/") : file;
163+
var path = projDir is not null && !Path.IsPathRooted(normalized)
164+
? Path.Join(projDir.FullName, normalized)
165+
: normalized;
166+
return Path.GetFullPath(path);
163167
}
164168

165169
private readonly string[] references;

0 commit comments

Comments
 (0)