Remove check for path starting with root, assume path is always relative to the root
This commit is contained in:
@@ -85,7 +85,15 @@ namespace Umbraco.Web.Common.AspNetCore
|
||||
private string MapPath(string root, string path)
|
||||
{
|
||||
var newPath = path.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
|
||||
return newPath.StartsWith(root) ? newPath : Path.Combine(root, newPath.TrimStart('~', '/'));
|
||||
|
||||
// TODO: This is a temporary error because we switched from IOHelper.MapPath to HostingEnvironment.MapPathXXX
|
||||
// IOHelper would check if the path passed in started with the root, and not prepend the root again if it did,
|
||||
// however if you are requesting a path be mapped, it should always assume the path is relative to the root, not
|
||||
// absolute in the file system. This error will help us find and fix improper uses, and should be removed once
|
||||
// all those uses have been found and fixed
|
||||
if (newPath.StartsWith(root)) throw new ArgumentException("The path appears to already be fully qualified. Please remove the call to MapPath");
|
||||
|
||||
return Path.Combine(root, newPath.TrimStart('~', '/'));
|
||||
}
|
||||
|
||||
public string ToAbsolute(string virtualPath)
|
||||
|
||||
Reference in New Issue
Block a user