use global commandline arguments to disable type detection by header
This commit is contained in:
parent
f7e4b26e39
commit
8362a2ee2d
@ -5,7 +5,7 @@ import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func isBinary(content []byte, _ int) bool {
|
||||
func isBinary(content []byte) bool {
|
||||
maybeStr := string(content)
|
||||
runeCnt := utf8.RuneCount(content)
|
||||
runeIndex := 0
|
||||
|
||||
10
http/data.go
10
http/data.go
@ -47,13 +47,9 @@ func (d *data) Check(path string) bool {
|
||||
return allow
|
||||
}
|
||||
|
||||
func (d *data) IsTypeDetectDisabled(path string) bool {
|
||||
for _, rule := range d.user.DisableTypeDetections {
|
||||
if rule.Matches(path) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
// ReadHeader implements rules.ReadHeader.
|
||||
func (d *data) ReadHeader() bool {
|
||||
return d.server.TypeDetectionByHeader
|
||||
}
|
||||
|
||||
func handle(fn handleFunc, prefix string, store *storage.Storage, server *settings.Server) http.Handler {
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
// Checker is a Rules checker.
|
||||
type Checker interface {
|
||||
Check(path string) bool
|
||||
IsTypeDetectDisabled(path string) bool
|
||||
ReadHeader() bool
|
||||
}
|
||||
|
||||
// Rule is a allow/disallow rule.
|
||||
|
||||
@ -30,17 +30,18 @@ func (s *Settings) GetRules() []rules.Rule {
|
||||
|
||||
// Server specific settings.
|
||||
type Server struct {
|
||||
Root string `json:"root"`
|
||||
BaseURL string `json:"baseURL"`
|
||||
Socket string `json:"socket"`
|
||||
TLSKey string `json:"tlsKey"`
|
||||
TLSCert string `json:"tlsCert"`
|
||||
Port string `json:"port"`
|
||||
Address string `json:"address"`
|
||||
Log string `json:"log"`
|
||||
EnableThumbnails bool `json:"enableThumbnails"`
|
||||
ResizePreview bool `json:"resizePreview"`
|
||||
EnableExec bool `json:"enableExec"`
|
||||
Root string `json:"root"`
|
||||
BaseURL string `json:"baseURL"`
|
||||
Socket string `json:"socket"`
|
||||
TLSKey string `json:"tlsKey"`
|
||||
TLSCert string `json:"tlsCert"`
|
||||
Port string `json:"port"`
|
||||
Address string `json:"address"`
|
||||
Log string `json:"log"`
|
||||
EnableThumbnails bool `json:"enableThumbnails"`
|
||||
ResizePreview bool `json:"resizePreview"`
|
||||
EnableExec bool `json:"enableExec"`
|
||||
TypeDetectionByHeader bool `json:"typeDetectionByHeader"`
|
||||
}
|
||||
|
||||
// Clean cleans any variables that might need cleaning.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user