v14: Validate file name to return correct error (#16419)

* Validate name

* Add missing case for HandleRename
This commit is contained in:
Nikolaj Geisle
2024-05-31 11:25:27 +02:00
committed by GitHub
parent 133f985293
commit 71e1b74337

View File

@@ -82,6 +82,11 @@ public abstract class FileServiceOperationBase<TRepository, TEntity, TOperationS
protected async Task<Attempt<TEntity?, TOperationStatus>> HandleCreateAsync(string name, string? parentPath, string? content, Guid userKey)
{
if (name.Contains('/'))
{
return Attempt.FailWithStatus<TEntity?, TOperationStatus>(InvalidName, default);
}
using ICoreScope scope = ScopeProvider.CreateCoreScope();
var path = GetFilePath(parentPath, name);
@@ -148,6 +153,11 @@ public abstract class FileServiceOperationBase<TRepository, TEntity, TOperationS
protected async Task<Attempt<TEntity?, TOperationStatus>> HandleRenameAsync(string path, string newName, Guid userKey)
{
if (newName.Contains('/'))
{
return Attempt.FailWithStatus<TEntity?, TOperationStatus>(InvalidName, default);
}
using ICoreScope scope = ScopeProvider.CreateCoreScope();
TEntity? entity = Repository.Get(path);