Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Umbraco.Cms.Api.Management.Controllers.StaticFile.Tree;
[ApiExplorerSettings(GroupName = "Static File")]
public class StaticFileTreeControllerBase : FileSystemTreeControllerBase
{
private static readonly string[] _allowedRootFolders = { "App_Plugins", "wwwroot" };
private static readonly string[] _allowedRootFolders = { $"{Path.DirectorySeparatorChar}App_Plugins", $"{Path.DirectorySeparatorChar}wwwroot" };

public StaticFileTreeControllerBase(IPhysicalFileSystem physicalFileSystem)
=> FileSystem = physicalFileSystem;
Expand All @@ -35,7 +35,7 @@ protected override FileSystemTreeItemPresentationModel[] GetAncestorModels(strin
? base.GetAncestorModels(path, includeSelf)
: Array.Empty<FileSystemTreeItemPresentationModel>();

private bool IsTreeRootPath(string path) => string.IsNullOrWhiteSpace(path);
private bool IsTreeRootPath(string path) => path == Path.DirectorySeparatorChar.ToString();

private bool IsAllowedPath(string path) => _allowedRootFolders.Contains(path) || _allowedRootFolders.Any(folder => path.StartsWith($"{folder}{Path.DirectorySeparatorChar}"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ internal static class StringPathExtensions
{
public static string SystemPathToVirtualPath(this string systemPath) => systemPath.Replace('\\', '/').TrimStart('~').EnsureStartsWith('/');

public static string VirtualPathToSystemPath(this string virtualPath) => virtualPath.TrimStart('/').Replace('/', Path.DirectorySeparatorChar);
public static string VirtualPathToSystemPath(this string virtualPath) => virtualPath.Replace('/', Path.DirectorySeparatorChar).EnsureStartsWith(Path.DirectorySeparatorChar);
}