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

Pushing text files result in a wrong mime type error #48

Open
gaelgatelement opened this issue Sep 27, 2023 · 1 comment
Open

Pushing text files result in a wrong mime type error #48

gaelgatelement opened this issue Sep 27, 2023 · 1 comment

Comments

@gaelgatelement
Copy link
Member

gaelgatelement commented Sep 27, 2023

Describe the bug

Using the following curl command :

curl -k -H 'Host: synapse.dev.local' -X POST --header 'Authorization: Bearer {user_access_token}' --header 'Content-Type: text/plain' --data-binary <text file> 'https://localhost/_matrix/media/v3/upload

When getting the file, Matrix content scanner returns the following error :

2023-09-27 16:21:04,922 - matrix_content_scanner.scanner.scanner - 518 - ERROR - GET-1348 - Mismatching MIME type (text/plain) and Content-Type header (text/plain; charset=UTF-8)
@reivilibre
Copy link
Contributor

Synapse appends UTF-8 charsets

    # Default to a UTF-8 charset for text content types.
    # ex, uses UTF-8 for 'text/css' but not 'text/css; charset=UTF-16'
    if media_type.lower() in TEXT_CONTENT_TYPES:
        content_type = media_type + "; charset=UTF-8"
    else:
        content_type = media_type

We need to only compare the 'essence' of the MIME type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants