Project

General

Profile

Bug #16100

Updated by Tom Clegg about 4 years ago

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. Content-Type. This is unreliable (and not just hypothetically -- users have been surprised by mysteriously broken previews). 

 For example, if the @/etc/mime.types@ Observed behavior: A 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 Desired behavior: A file called "bmx.txt", regardless of content, 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 be served with @Content-Type: text/plain@ because "TypeByExtension()":https://golang.org/pkg/mime/#TypeByExtension returns "text/plain" for a common extension like @.txt@ that's not in the built-in list, and log a warning if it's missing. 
 ".txt".

Back