No way to upload files with "text/plain; charset=utf-8" filetype #3793

Closed
opened 2025-11-02 05:25:25 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @dtluna on GitHub (Aug 15, 2019).

  • Gitea version (or commit ref): Gitea version 1.9.1 built with GNU Make 4.2.1, go1.12.8 : bindata, sqlite, pam
  • Git version: git version 2.22.1
  • Operating system: Arch Linux ARM
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
Aug 15 18:40:17 dtluna.net gitea[21743]: 2019/08/15 18:40:17 ...s/repo/attachment.go:58:UploadAttachment() [I] Attachment with type text/plain; charset=utf-8 blocked from upload

Description

I have

ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain; charset=utf-8"

In my /etc/gitea/app.ini, but I still cannot upload checksums.txt at https://git.dtluna.net/dtluna/fallhack/releases/edit/v1.0.1

...

Screenshots

upload

Originally created by @dtluna on GitHub (Aug 15, 2019). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): Gitea version 1.9.1 built with GNU Make 4.2.1, go1.12.8 : bindata, sqlite, pam - Git version: git version 2.22.1 - Operating system: Arch Linux ARM - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ``` Aug 15 18:40:17 dtluna.net gitea[21743]: 2019/08/15 18:40:17 ...s/repo/attachment.go:58:UploadAttachment() [I] Attachment with type text/plain; charset=utf-8 blocked from upload ``` ## Description I have ```ini ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain; charset=utf-8" ``` In my `/etc/gitea/app.ini`, but I still cannot upload [checksums.txt](https://github.com/go-gitea/gitea/files/3506791/checksums.txt) at https://git.dtluna.net/dtluna/fallhack/releases/edit/v1.0.1 ... ## Screenshots ![upload](https://user-images.githubusercontent.com/25333996/63118408-6adf3480-bfa6-11e9-9cfa-1167ff8927c0.png) <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/bug label 2025-11-02 05:25:25 -06:00
Author
Owner

@lunny commented on GitHub (Aug 16, 2019):

There are two allowed_types, you may changed the wrong section. But of course, it's still a bug.

[repository.upload]
ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain"

[attachment]
ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain"

@lunny commented on GitHub (Aug 16, 2019): There are two allowed_types, you may changed the wrong section. But of course, it's still a bug. ```ini [repository.upload] ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain" [attachment] ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain" ```
Author
Owner

@dtluna commented on GitHub (Aug 16, 2019):

@lunny I am speaking specifically about the [attachment] section

@dtluna commented on GitHub (Aug 16, 2019): @lunny I am speaking specifically about the `[attachment]` section
Author
Owner

@lunny commented on GitHub (Aug 16, 2019):

For release, you should change repository.upload section not attachment

@lunny commented on GitHub (Aug 16, 2019): For release, you should change repository.upload section not attachment
Author
Owner

@dtluna commented on GitHub (Aug 16, 2019):

@lunny
I have this in my config

 [repository.upload]
 ;Whether repository file uploads are enabled. Defaults to `true`
 ENABLED = true
 ;Path for uploads. Defaults to `data/tmp/uploads` (tmp gets deleted on gitea restart)
 TEMP_PATH = data/tmp/uploads
 ; One or more allowed types, e.g. image/jpeg|image/png. Nothing means any file type
 ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain"

and I still cannot upload checksum.txt. But if I have this:

[attachment]
; Whether attachments are enabled. Defaults to `true`
ENABLED = true
; Path for attachments. Defaults to `data/attachments`
PATH = data/attachments
; One or more allowed types, e.g. image/jpeg|image/png
ALLOWED_TYPES = */*

then I can upload checksum.txt. I am positive that [attachment] is the section to configure.

@dtluna commented on GitHub (Aug 16, 2019): @lunny I have this in my config ```ini [repository.upload] ;Whether repository file uploads are enabled. Defaults to `true` ENABLED = true ;Path for uploads. Defaults to `data/tmp/uploads` (tmp gets deleted on gitea restart) TEMP_PATH = data/tmp/uploads ; One or more allowed types, e.g. image/jpeg|image/png. Nothing means any file type ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain" ``` and I still cannot upload `checksum.txt`. But if I have this: ```ini [attachment] ; Whether attachments are enabled. Defaults to `true` ENABLED = true ; Path for attachments. Defaults to `data/attachments` PATH = data/attachments ; One or more allowed types, e.g. image/jpeg|image/png ALLOWED_TYPES = */* ``` then I can upload `checksum.txt`. I am positive that `[attachment]` is the section to configure.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3793