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
@@ -131,34 +159,6 @@ class CLocalizationDummy final : public CLocalizationInterface
131159// Global localization interface
132160CLocalizationInterface* g_pLocalization = new CLocalizationDummy();
133161
134- // Helper functions
135- namespace
136- {
137- bool ValidatePath (const SString& path)
138- {
139- if (path.empty () || path.length () >= MAX_PATH) // >= instead of > to leave room for null terminator
140- return false ;
141-
142- if (path.Contains (" .." ) || path.Contains (" ..\\ " ) || path.Contains (" ../" ))
143- return false ;
144-
145- // Check for null bytes
146- if (path.find (' \0 ' ) != SString::npos)
147- return false ;
148-
149- if (path.Contains (" :" ) && !path.BeginsWith (" C:\\ " ) && !path.BeginsWith (" D:\\ " ) &&
150- !path.BeginsWith (" E:\\ " ) && !path.BeginsWith (" F:\\ " ) && !path.BeginsWith (" G:\\ " ))
151- return false ;
152-
153- // Check for special characters
154- if (path.Contains (" \\\\ ?\\ " ) || path.Contains (" \\\\ .\\ " )|| // Device namespace paths
155- path.Contains (" %" ) || path.Contains (" $" ))
156- return false ;
157-
158- return true ;
159- }
160- }
161-
162162// ////////////////////////////////////////////////////////
163163//
164164// InitLocalization
@@ -1655,4 +1655,4 @@ void HandleOnQuitCommand()
16551655 ShellExecuteNonBlocking (strOperation.empty () ? NULL : strOperation.c_str (), strFile.c_str (),
16561656 strParameters.empty () ? NULL : strParameters.c_str (), strDirectory.empty () ? NULL : strDirectory.c_str (), nShowCmd);
16571657 }
1658- }
1658+ }
0 commit comments