Support custom mime type mapping for text files #16304

Merged
lunny merged 5 commits from raw-text-mime-type-mapping into main 2021-06-30 21:31:54 +00:00
Contributor

In #15133 a repository.mimetype_mapping configuration was added, but it is currently only applied for binary files.
This PR also applies the custom mime type mappings for text files.

Fixes #8152

⚠️ WARNING ⚠️

Enabling this feature may have security implications. Administrators should carefully consider which mimetypes they wish to map.

In #15133 a `repository.mimetype_mapping` configuration was added, but it is currently only applied for binary files. This PR also applies the custom mime type mappings for text files. Fixes #8152 ## :warning: WARNING :warning: Enabling this feature may have security implications. Administrators should carefully consider which mimetypes they wish to map.
6543 (Migrated from github.com) approved these changes 2021-06-29 22:38:44 +00:00
KN4CK3R (Migrated from github.com) reviewed 2021-06-30 06:21:46 +00:00
KN4CK3R (Migrated from github.com) commented 2021-06-30 06:21:46 +00:00
		if mappedMimeType == "" {
			mappedMimeType = "text/plain"
		}
		ctx.Resp.Header().Set("Content-Type", mappedMimeType+"; charset="+strings.ToLower(cs))
```suggestion if mappedMimeType == "" { mappedMimeType = "text/plain" } ctx.Resp.Header().Set("Content-Type", mappedMimeType+"; charset="+strings.ToLower(cs)) ```
KN4CK3R (Migrated from github.com) approved these changes 2021-06-30 20:47:40 +00:00
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/gitea#16304
No description provided.