1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-12-09 05:29:12 +00:00
This commit is contained in:
Hyper_ 2025-12-07 16:20:45 -03:00 committed by GitHub
commit ddb67a8100
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -58,7 +58,7 @@ class FileUtil
*/
public static var PROTECTED_PATHS(get, never):Array<String>;
public static function get_PROTECTED_PATHS():Array<String>
static function get_PROTECTED_PATHS():Array<String>
{
final protected:Array<String> = [
'',
@ -83,7 +83,8 @@ class FileUtil
#if sys
for (i in 0...protected.length)
{
protected[i] = sys.FileSystem.fullPath(Path.join([gameDirectory, protected[i]]));
// On Linux 'fullPath' just makes most of these null which actually just makes the paths unprotected
protected[i] = #if !linux sys.FileSystem.fullPath #end (Path.join([gameDirectory, protected[i]]));
}
#end
@ -1306,8 +1307,26 @@ class FileUtilSandboxed
#if sys
// TODO: figure out how to get "real" path of symlinked paths
final realPath:String = sys.FileSystem.fullPath(Path.join([FileUtil.gameDirectory, sanitized.join('/')]));
if (!realPath.startsWith(FileUtil.gameDirectory))
#if linux
// The implementation on Linux fails if the path doesn't exist
var realPath:Null<String> = null;
var unresolvedSegments:Array<String> = [];
while (realPath == null && sanitized.length > 0)
{
realPath = sys.FileSystem.fullPath(Path.join([FileUtil.gameDirectory].concat(sanitized)));
if (realPath == null) unresolvedSegments.unshift(sanitized.pop() ?? continue);
}
if (unresolvedSegments.length > 0)
{
if (realPath != null) unresolvedSegments.unshift(realPath);
realPath = Path.join(unresolvedSegments);
}
#else
final realPath:Null<String> = sys.FileSystem.fullPath(Path.join([FileUtil.gameDirectory].concat(sanitized)));
#end
if (realPath == null || !realPath.startsWith(FileUtil.gameDirectory))
{
return FileUtil.gameDirectory;
}