Skip to content

v14: Validate file name to return correct error#16419

Merged
Migaroez merged 2 commits intov14/devfrom
v14/bugfix/return-correct-error-for-script
May 31, 2024
Merged

v14: Validate file name to return correct error#16419
Migaroez merged 2 commits intov14/devfrom
v14/bugfix/return-correct-error-for-script

Conversation

@Zeegaan
Copy link
Copy Markdown
Member

@Zeegaan Zeegaan commented May 27, 2024

Notes

  • If the file name contains /, it is invalid, as we do have parenpath, it would make no sense to have a / in a filename

How to test

  • call the umbraco/management/api/v1/script endpoint with:
{
  "name": "hell/o.js",
  "content": "<string>"
}
  • This should now yield a InvalidName error, not a ParentNotFound error

Copy link
Copy Markdown
Contributor

@Migaroez Migaroez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple, elegant, functional 👨‍🍳

Comment on lines +85 to +88
if (name.Contains("/"))
{
return Attempt.FailWithStatus<TEntity?, TOperationStatus>(InvalidName, default);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon we need this both here and in HandleRenameAsync?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 😁

@Migaroez Migaroez merged commit 71e1b74 into v14/dev May 31, 2024
@Migaroez Migaroez deleted the v14/bugfix/return-correct-error-for-script branch May 31, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants