* update string extensions IsFullPath to support more filepaths with new built-in Path.IsPathFullyQualified
* resolve TODO to switch to Path.IsPathFullyQualified supported from .NET Standard 2.1
* Use content root instead of web root for uploaded images
* Un-break a breaking change
* handle special parsing of AngularJS json response
* change htmlId selector to support html id's with numbers
* remove bad test case
* test IsFullPath without tricky UNC paths that are not useful
Co-authored-by: Bjarke Berg <mail@bergmania.dk>
(cherry picked from commit d18dc92137)
39 lines
940 B
C#
39 lines
940 B
C#
using Umbraco.Cms.Core.Hosting;
|
|
|
|
namespace Umbraco.Cms.Core.IO;
|
|
|
|
public class IOHelperWindows : IOHelper
|
|
{
|
|
public IOHelperWindows(IHostingEnvironment hostingEnvironment)
|
|
: base(hostingEnvironment)
|
|
{
|
|
}
|
|
|
|
public override bool PathStartsWith(string path, string root, params char[] separators)
|
|
{
|
|
// either it is identical to root,
|
|
// or it is root + separator + anything
|
|
if (separators == null || separators.Length == 0)
|
|
{
|
|
separators = new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
|
|
}
|
|
|
|
if (!path.StartsWith(root, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (path.Length == root.Length)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (path.Length < root.Length)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return separators.Contains(path[root.Length]);
|
|
}
|
|
}
|