[PR #3617] [CLOSED] Allow mime types to match based off of prefix #17020

Closed
opened 2025-11-02 12:24:25 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/3617
Author: @mqudsi
Created: 3/3/2018
Status: Closed

Base: mainHead: attachment_allow_prefix


📝 Commits (1)

  • 3b9396c Allow mime types to match based off of class

📊 Changes

1 file changed (+6 additions, -2 deletions)

View changed files

📝 modules/upload/filetype.go (+6 -2)

📄 Description

The old behavior prevented simple file types like "text/plain" from
being uploaded since browsers upload them with the charset as well (e.g.
text/plain charset=utf-8) without specifying all possible charsets.

Additionally, this allows for blanket includes like "text/" or "image/"
by class type.

There should be minimal risk introduced here as mime types are generally
hierarchical, but an alternative approach would be the equivalent of

if allowed.endsWith("*") && strings.HasPrefix(fileType,
    allowed.substr(0, allowed.length - 1) { ....

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/3617 **Author:** [@mqudsi](https://github.com/mqudsi) **Created:** 3/3/2018 **Status:** ❌ Closed **Base:** `main` ← **Head:** `attachment_allow_prefix` --- ### 📝 Commits (1) - [`3b9396c`](https://github.com/go-gitea/gitea/commit/3b9396c178ce4dc4d28ed2b7d3a6cbae634c5f64) Allow mime types to match based off of class ### 📊 Changes **1 file changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `modules/upload/filetype.go` (+6 -2) </details> ### 📄 Description The old behavior prevented simple file types like "text/plain" from being uploaded since browsers upload them with the charset as well (e.g. `text/plain charset=utf-8`) without specifying all possible charsets. Additionally, this allows for blanket includes like "text/" or "image/" by class type. There should be minimal risk introduced here as mime types are generally hierarchical, but an alternative approach would be the equivalent of ``` if allowed.endsWith("*") && strings.HasPrefix(fileType, allowed.substr(0, allowed.length - 1) { .... ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:24:25 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#17020