17
17
#include < array>
18
18
#include < locale.h>
19
19
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
+
20
48
// ////////////////////////////////////////////////////////
21
49
//
22
50
// CheckLibVersions
@@ -131,34 +159,6 @@ class CLocalizationDummy final : public CLocalizationInterface
131
159
// Global localization interface
132
160
CLocalizationInterface* g_pLocalization = new CLocalizationDummy();
133
161
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
-
162
162
// ////////////////////////////////////////////////////////
163
163
//
164
164
// InitLocalization
@@ -1655,4 +1655,4 @@ void HandleOnQuitCommand()
1655
1655
ShellExecuteNonBlocking (strOperation.empty () ? NULL : strOperation.c_str (), strFile.c_str (),
1656
1656
strParameters.empty () ? NULL : strParameters.c_str (), strDirectory.empty () ? NULL : strDirectory.c_str (), nShowCmd);
1657
1657
}
1658
- }
1658
+ }
0 commit comments