Closed Android-X13 closed 1 month ago
I don't think there was a relevant change. But with name=Test
you prevent a check of the filename extension. If you remove the name
parameter, the upload filename test.jpg
is used.
I'm pretty sure I could use it in older versions with no problem... I don't remember which version though.
This is how the attachment looks now:
When using the name
parameter, instead of the filename test.jpg
it would show the name provided.
What is the point of the name parameter in the API docs if it's never used?
It is used and overrides the upload filename. If you pass name=test2.jpg
your upload is named test2.jpg
.
To add some clarification, the problem you are having is that when you pass name=Test
we perform an extension check that honors what is provided in ALLOWED_TYPES
in your app.ini
's [attachment]
section. If you don't explicitly define this key, we have a default that is used (see here for more details). Since Test
doesn't have an extension that is known in this list, we will reject it.
You have a few options to solve this:
Test.jpg
ALLOWED_TYPES
key nothing or pass a */*
(this is mentioned in the docs given above)However, if you want to allow a file with no extension, this does not look possible currently given the code that I see. We don't accept empty entries in ALLOWED_TYPES
and we always expect at least a .
prefix when you pass an extension (e.g. we would allow .webp
but ignore webp
during verification).
@kemzeb thanks for the info.
My intention was not to add a file with no extension. As I've already said above I thought that the name
parameter just names the attachment in the web interface. I recall that this was the case in a previous version, but if I'm terribly mistaken then I guess the issue can be closed?
No problem.
After exploring the following commits:
To me it looks like we have been performing these checks on the name
query param every since the APIs inception.
Description
In previous versions I used to be able to create issue attachments via the API like so (as per the docs):
However now the server responds:
The attachment is created fine if the name query parameter is removed.
Gitea Version
1.21.11
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Binary download, systemd
Database
None