Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

Commit bb44e80

Browse files
committed
Don't damage UNC paths
1 parent 51dc1c6 commit bb44e80

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

CPPCheckPlugin/SourceFile.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,18 @@ public VCCompilerVersion vcCompilerVersion
169169

170170
private static string cleanPath(string path)
171171
{
172-
string result = path.Replace("\"", "").Replace("\\\\", "\\");
173-
if (result.EndsWith("\\"))
172+
string result = path.Replace("\"", "");
173+
const string doubleBackSlash = "\\\\";
174+
const string singleBackSlash = "\\";
175+
if( result.StartsWith( doubleBackSlash )) {
176+
// UNC path - must preserve the leading double slash
177+
result = singleBackSlash + result.Replace( doubleBackSlash, singleBackSlash );
178+
} else {
179+
result = result.Replace( doubleBackSlash, singleBackSlash );
180+
}
181+
if (result.EndsWith(singleBackSlash))
174182
result = result.Substring(0, result.Length - 1);
175-
if (result.StartsWith("\\"))
183+
if (result.StartsWith(singleBackSlash) && !result.StartsWith(doubleBackSlash))
176184
result = result.Substring(1);
177185
return result;
178186
}

0 commit comments

Comments
 (0)