v14: Validate file name to return correct error (#16419)
* Validate name * Add missing case for HandleRename
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user