Convert path to absolute
This commit is contained in:
@@ -29,6 +29,7 @@ public sealed class RichTextEditorPastedImages
|
||||
private readonly IPublishedUrlProvider _publishedUrlProvider;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly string _tempFolderAbsolutePath;
|
||||
|
||||
public RichTextEditorPastedImages(
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
@@ -52,6 +53,9 @@ public sealed class RichTextEditorPastedImages
|
||||
_mediaUrlGenerators = mediaUrlGenerators;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
_publishedUrlProvider = publishedUrlProvider;
|
||||
|
||||
_tempFolderAbsolutePath = _hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempImageUploads);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,12 +89,14 @@ public sealed class RichTextEditorPastedImages
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsValidPath(tmpImgPath) == false)
|
||||
|
||||
var absoluteTempImagePath = Path.GetFullPath(_hostingEnvironment.MapPathContentRoot(tmpImgPath));
|
||||
|
||||
if (IsValidPath(absoluteTempImagePath) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var absoluteTempImagePath = _hostingEnvironment.MapPathContentRoot(tmpImgPath);
|
||||
var fileName = Path.GetFileName(absoluteTempImagePath);
|
||||
var safeFileName = fileName.ToSafeFileName(_shortStringHelper);
|
||||
|
||||
@@ -191,5 +197,8 @@ public sealed class RichTextEditorPastedImages
|
||||
return htmlDoc.DocumentNode.OuterHtml;
|
||||
}
|
||||
|
||||
private bool IsValidPath(string imagePath) => imagePath.StartsWith(Constants.SystemDirectories.TempImageUploads);
|
||||
private bool IsValidPath(string imagePath)
|
||||
{
|
||||
return imagePath.StartsWith(_tempFolderAbsolutePath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user