From 5598cc2491f32ca6329d2c1e7641b55cef09eb8f Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 23 Mar 2023 09:20:20 +0100 Subject: [PATCH] Convert path to absolute --- .../PropertyEditors/RichTextEditorPastedImages.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RichTextEditorPastedImages.cs b/src/Umbraco.Infrastructure/PropertyEditors/RichTextEditorPastedImages.cs index 569f38139d..5044a5b13e 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RichTextEditorPastedImages.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/RichTextEditorPastedImages.cs @@ -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); + } /// @@ -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); + } }