Uploading attachment with invalid file name returns HTTP 200
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 354
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 43
Description
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Describe the bug
When uploading an attachment as described in the docs with a file name that contains a / the file is accepted but the file name is altered: The file name will be only the part after the last /.
To Reproduce
Steps to reproduce the behavior:
- Create a card
- Upload an attachment with file name
foo/bar/example.pdf(curl -u <User>:<AppPassword> --basic -F "file=@<local-sample-file-name>;filename=foo/bar/example.pdf" -F "type=file" https://<your-instance-FQDN>/apps/deck/api/v1.0/boards/<boardId>/stacks/<stackId>/cards/<cardId>/attachments) - Check the attachments
- See a file "example.pdf"
Expected behavior
I expect an HTTP status code 400 to be thrown as I provided an invalid file name. Since I receive an HTTP status code 200, I assume that my request has been processed as I submitted it.
Screenshots
See above.
Client details:
Not applicable
Background:
I use a programm to upload attachments. I prefix the attachments with the card id to prevent duplicates. Due to a bug in my application the absolute path of the file to upload was used for the upload request. Example:
- Absolute file path:
/root/foo.pdf - Card ID:
50
Expected file name in request:50_foo.pdf
Actual (due bug) file name in request:50_/root/foo.pdf
Result in Nextcloud Deck:foo.pdf,foo (1).pdf,foo (2).pdf, ...
Server details
Operating system: Docker
Web server: AIO
Database: AIO
PHP version: 8.3.25
Nextcloud version: Nextcloud Hub 10 (31.0.8)
Where did you install Nextcloud from: AIO
Signing status:
No errors have been found.
List of activated apps:
If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder
Nextcloud configuration:
Not applicable
Are you using an external user-backend, if yes which one: No
Logs
Nextcloud log (data/nextcloud.log)
Nothing regarding deck.
Browser log
Not applicable
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Deck attachment upload API endpoint shown in the reproduction command and reproduce the request with the filename foo/bar/example.pdf. Check the upload response and stored attachment name; done means invalid filenames receive HTTP 400 rather than HTTP 200 and are not silently reduced to example.pdf.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100