Project

General

Profile

Actions

Bug #16100

closed

[keep-web] Avoid sniffing for content type when file extension matches a MIME type

Added by Tom Clegg about 4 years ago. Updated about 4 years ago.

Status:
Resolved
Priority:
Normal
Assigned To:
Category:
Keep
Target version:
Story points:
0.5
Release relationship:
Auto

Description

Currently, when serving a GET request for a file, the WebDAV service uses the Go standard library's content sniffing feature to guess an appropriate Content-Type if the filename extension is not listed in /etc/mime.types or a small built-in list of extensions. This is unreliable (and not just hypothetically -- users have been surprised by mysteriously broken previews).

For example, if the /etc/mime.types file does not exist, a file called "bmx.txt" containing the text "BMX bikes are awesome.\n" is currently served with Content-Type: image/bmp because the first two bytes "BM" satisfy the signature for a BMP image file, and this causes it to render incorrectly in the browser.

To avoid this problem:

Keep-web OS packages should list the package providing /etc/mime.types -- "mailcap" on centos, "mime-support" on debian and ubuntu -- as a dependency.

At startup, keep-web should check the mime type for a common extension like .txt that's not in the built-in list, and log a warning if it's missing.


Subtasks 1 (0 open1 closed)

Task #16147: Review 16100-mime-typesResolvedTom Clegg02/14/2020Actions

Related issues

Related to Arvados - Idea #15348: [pam] PAM module in GoResolvedTom Clegg06/23/2020Actions
Actions

Also available in: Atom PDF