Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Content-Type for /upload #1761

Closed

Conversation

KitsuneRal
Copy link
Member

@KitsuneRal KitsuneRal commented Dec 26, 2018

Because this is what the error message from the server says if I omit Content-Type. There might be other endpoints with the same bug - feel free to indicate and I'll add them to the PR.

Because this is what error message from the server says.

Signed-off-by: Alexey Rusakov <[email protected]>
@KitsuneRal KitsuneRal added the spec-bug Something which is in the spec, but is wrong label Dec 26, 2018
@turt2live
Copy link
Member

This kinda feels like a synapse bug and not a spec bug. Although good to provide, I can't really think of a reason why the media repo absolutely needs to know what you're uploading. If it wants to verify that you're only uploading images (for example), it shouldn't be relying on the user-supplied value anyways.

@KitsuneRal
Copy link
Member Author

Well, given that the sending client by definition has a bit more information on the MIME type and that the parameter is there anyway, I believe the question of verification does not really stand. With that said, being able to rely on the server's guesswork would be handy for clients. Qt knows how to detect MIME types so I can deduce them from the content; so I as a QMatrixClient developer I don't have a strong opinion on this. But other clients might not necessarily have a MIME database at hand.

@turt2live
Copy link
Member

The mimetype is optional everywhere else in the spec. Although helpful to supply, the sending client shouldn't be required to send the type to the media repo.

My argument about server side validation is more about preventing users from uploading certain types of media. The server shouldn't trust that the client is sending the right mimetype and may have to figure out what the real mimetype is. The client -supplied value is really only a guideline for future downloaders, and the media repo can easily serve a generic non-descript file.

@turt2live
Copy link
Member

I've since been convinced that it should be required, although I didn't document it here (sorry). Asking for review from the rest of the team to spark conversation.

@turt2live turt2live requested a review from a team June 15, 2019 04:31
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

Given that synapse currently requires you to give a content-type, we should certainly either fix synapse to match the spec, or the spec to match synapse.

I've got to say, though, my first reaction is to agree with Travis's first impression that this is a synapse bug rather than a spec bug. My expectation would be that the server should treat the content-type as application/octet-stream by default.

We should also consider specifying what the server is actually supposed to do with the content-type. Does it just parrot it back for future download requests (in which case, is it supposed to validate it somehow? Are there security risks associated with allowing arbitrary content-types?) or does it also use it as a basis for decisions such as whether to thumbnail?

@KitsuneRal
Copy link
Member Author

Should this be turned to a Synapse bug then?

@turt2live
Copy link
Member

@KitsuneRal I suspect this needs a bit more input from the spec core team. Possibly just writing a MSC to answer vdh's questions will be enough to make the spec and Synapse match once again.

@KitsuneRal
Copy link
Member Author

Can I just turn this PR into an MSC or is it better to spawn a separate thing?

@turt2live
Copy link
Member

I wouldn't be bothered by it, though the changes to the spec can't be in the same PR as the MSC

@KitsuneRal
Copy link
Member Author

Oh, right; a separate PR then.

@aaronraimist
Copy link
Contributor

#2701 clarifies this

@richvdh
Copy link
Member

richvdh commented Aug 3, 2021

this seems to have been superceded by #2701.

@richvdh richvdh closed this Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec-bug Something which is in the spec, but is wrong
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants