Skip to content

Commit 8d3d8c1

Browse files
committed
Test fix for build error
1 parent 802508b commit 8d3d8c1

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

Client/loader/MainFunctions.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,34 @@
1717
#include <array>
1818
#include <locale.h>
1919

20+
// Function must be at the start to fix odd compile error (Didn't happen locally but does in build server)
21+
namespace
22+
{
23+
bool ValidatePath(const SString& path)
24+
{
25+
if (path.empty() || path.length() >= MAX_PATH) // >= instead of > to leave room for null terminator
26+
return false;
27+
28+
if (path.Contains("..") || path.Contains("..\\") || path.Contains("../"))
29+
return false;
30+
31+
// Check for null bytes
32+
if (path.find('\0') != SString::npos)
33+
return false;
34+
35+
if (path.Contains(":") && !path.BeginsWith("C:\\") && !path.BeginsWith("D:\\") &&
36+
!path.BeginsWith("E:\\") && !path.BeginsWith("F:\\") && !path.BeginsWith("G:\\"))
37+
return false;
38+
39+
// Check for special characters
40+
if (path.Contains("\\\\?\\") || path.Contains("\\\\.\\")|| // Device namespace paths
41+
path.Contains("%") || path.Contains("$"))
42+
return false;
43+
44+
return true;
45+
}
46+
}
47+
2048
//////////////////////////////////////////////////////////
2149
//
2250
// CheckLibVersions
@@ -130,34 +158,6 @@ class CLocalizationDummy final : public CLocalizationInterface
130158
// Global localization interface
131159
CLocalizationInterface* g_pLocalization = new CLocalizationDummy();
132160

133-
// Helper functions
134-
namespace
135-
{
136-
bool ValidatePath(const SString& path)
137-
{
138-
if (path.empty() || path.length() >= MAX_PATH) // >= instead of > to leave room for null terminator
139-
return false;
140-
141-
if (path.Contains("..") || path.Contains("..\\") || path.Contains("../"))
142-
return false;
143-
144-
// Check for null bytes
145-
if (path.find('\0') != SString::npos)
146-
return false;
147-
148-
if (path.Contains(":") && !path.BeginsWith("C:\\") && !path.BeginsWith("D:\\") &&
149-
!path.BeginsWith("E:\\") && !path.BeginsWith("F:\\") && !path.BeginsWith("G:\\"))
150-
return false;
151-
152-
// Check for special characters
153-
if (path.Contains("\\\\?\\") || path.Contains("\\\\.\\")|| // Device namespace paths
154-
path.Contains("%") || path.Contains("$"))
155-
return false;
156-
157-
return true;
158-
}
159-
}
160-
161161
//////////////////////////////////////////////////////////
162162
//
163163
// InitLocalization
@@ -1654,4 +1654,4 @@ void HandleOnQuitCommand()
16541654
ShellExecuteNonBlocking(strOperation.empty() ? NULL : strOperation.c_str(), strFile.c_str(),
16551655
strParameters.empty() ? NULL : strParameters.c_str(), strDirectory.empty() ? NULL : strDirectory.c_str(), nShowCmd);
16561656
}
1657-
}
1657+
}

0 commit comments

Comments
 (0)