From 71e1b74337ba40168d55b5933e59da89308e7ec9 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Fri, 31 May 2024 11:25:27 +0200 Subject: [PATCH] v14: Validate file name to return correct error (#16419) * Validate name * Add missing case for HandleRename --- src/Umbraco.Core/Services/FileServiceOperationBase.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Umbraco.Core/Services/FileServiceOperationBase.cs b/src/Umbraco.Core/Services/FileServiceOperationBase.cs index 703465a1b3..e7b392d949 100644 --- a/src/Umbraco.Core/Services/FileServiceOperationBase.cs +++ b/src/Umbraco.Core/Services/FileServiceOperationBase.cs @@ -82,6 +82,11 @@ public abstract class FileServiceOperationBase> HandleCreateAsync(string name, string? parentPath, string? content, Guid userKey) { + if (name.Contains('/')) + { + return Attempt.FailWithStatus(InvalidName, default); + } + using ICoreScope scope = ScopeProvider.CreateCoreScope(); var path = GetFilePath(parentPath, name); @@ -148,6 +153,11 @@ public abstract class FileServiceOperationBase> HandleRenameAsync(string path, string newName, Guid userKey) { + if (newName.Contains('/')) + { + return Attempt.FailWithStatus(InvalidName, default); + } + using ICoreScope scope = ScopeProvider.CreateCoreScope(); TEntity? entity = Repository.Get(path);