Extended file manager to support the new interfaces for downloading via url. Improved the handling of compressing and decompressing. Seperated file manager controllers. Updated mooncore versions
This commit is contained in:
25
Moonlight.ApiServer/Helpers/FilePathHelper.cs
Normal file
25
Moonlight.ApiServer/Helpers/FilePathHelper.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace Moonlight.ApiServer.Helpers;
|
||||
|
||||
public class FilePathHelper
|
||||
{
|
||||
public static string SanitizePath(string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
return string.Empty;
|
||||
|
||||
// Normalize separators
|
||||
path = path.Replace('\\', '/');
|
||||
|
||||
// Remove ".." and "."
|
||||
var parts = path.Split('/', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Where(part => part != ".." && part != ".");
|
||||
|
||||
var sanitized = string.Join("/", parts);
|
||||
|
||||
// Ensure it does not start with a slash
|
||||
if (sanitized.StartsWith('/'))
|
||||
sanitized = sanitized.TrimStart('/');
|
||||
|
||||
return sanitized;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user