mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-12 10:40:24 +01:00
Prevent directory browsing
This commit is contained in:
@@ -102,7 +102,17 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
private string GetDashboardResourcePath(string virtualPath)
|
private string GetDashboardResourcePath(string virtualPath)
|
||||||
{
|
{
|
||||||
return Path.Combine(DashboardUIPath, virtualPath.Replace('/', Path.DirectorySeparatorChar));
|
var rootPath = DashboardUIPath;
|
||||||
|
|
||||||
|
var fullPath = Path.Combine(rootPath, virtualPath.Replace('/', Path.DirectorySeparatorChar));
|
||||||
|
|
||||||
|
// Don't allow file system access outside of the source folder
|
||||||
|
if (!_fileSystem.ContainsSubPath(rootPath, fullPath))
|
||||||
|
{
|
||||||
|
throw new UnauthorizedAccessException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user