Skip to content

fix(files): validate dropped filenames before upload - #63997

Open
hamza221 wants to merge 2 commits into
masterfrom
fix/validate-name-drag-and-drop
Open

fix(files): validate dropped filenames before upload#63997
hamza221 wants to merge 2 commits into
masterfrom
fix/validate-name-drag-and-drop

Conversation

@hamza221

@hamza221 hamza221 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

When uploading a file with a forbidden name test\ as an example it behaves differently depending on the upload method:

  • Drag and drop -> reaches DAV and you get no concise user facing error
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:o="http://owncloud.org/ns">
  <s:exception>OCA\DAV\Connector\Sabre\Exception\InvalidPath</s:exception>
  <s:message>"\" is not allowed inside a file or folder name.</s:message>
  <o:retry xmlns:o="o:">false</o:retry>
  <o:reason xmlns:o="o:">"\" is not allowed inside a file or folder name.</o:reason>
</d:error>

  • Through the upload button it gets renamed

For the sake of simplicity added a check before upload on drag and drop with error handling

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI
    Assisted-by: Codex:gpt-5.6-sol

Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
@hamza221 hamza221 self-assigned this Sep 3, 2026
@hamza221
hamza221 requested review from a team and skjnldsv as code owners September 3, 2026 11:54
@hamza221
hamza221 removed the request for review from a team September 3, 2026 11:54
@hamza221 hamza221 added the bug label Sep 3, 2026
@hamza221 hamza221 added 3. to review Waiting for reviews feature: files team: Files Code maintained by 📁 Files team labels Sep 3, 2026
@hamza221 hamza221 added this to the Nextcloud 36 milestone Sep 3, 2026
@hamza221

hamza221 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

/backport 53e8968 to stable35

@hamza221

hamza221 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

/backport 53e8968 to stable34

@hamza221

hamza221 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

/backport 53e8968 to stable33

@hamza221

This comment was marked as outdated.

@hamza221

hamza221 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

/compile

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
export async function onDropExternalFiles(root: RootDirectory, destination: IFolder, contents: INode[]): Promise<Upload[]> {
const invalidEntry = findInvalidDroppedEntry(root)
if (invalidEntry) {
showError(t('files', 'Cannot upload "{path}": {reason}', invalidEntry))

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.

This should rather give the user a change to rename it to something valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants