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"
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isBinary(content []byte, _ int) bool {
|
func isBinary(content []byte) bool {
|
||||||
maybeStr := string(content)
|
maybeStr := string(content)
|
||||||
runeCnt := utf8.RuneCount(content)
|
runeCnt := utf8.RuneCount(content)
|
||||||
runeIndex := 0
|
runeIndex := 0
|
||||||
|
|||||||
10
http/data.go
10
http/data.go
@ -47,13 +47,9 @@ func (d *data) Check(path string) bool {
|
|||||||
return allow
|
return allow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *data) IsTypeDetectDisabled(path string) bool {
|
// ReadHeader implements rules.ReadHeader.
|
||||||
for _, rule := range d.user.DisableTypeDetections {
|
func (d *data) ReadHeader() bool {
|
||||||
if rule.Matches(path) {
|
return d.server.TypeDetectionByHeader
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handle(fn handleFunc, prefix string, store *storage.Storage, server *settings.Server) http.Handler {
|
func handle(fn handleFunc, prefix string, store *storage.Storage, server *settings.Server) http.Handler {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import (
|
|||||||
// Checker is a Rules checker.
|
// Checker is a Rules checker.
|
||||||
type Checker interface {
|
type Checker interface {
|
||||||
Check(path string) bool
|
Check(path string) bool
|
||||||
IsTypeDetectDisabled(path string) bool
|
ReadHeader() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rule is a allow/disallow rule.
|
// Rule is a allow/disallow rule.
|
||||||
|
|||||||
@ -41,6 +41,7 @@ type Server struct {
|
|||||||
EnableThumbnails bool `json:"enableThumbnails"`
|
EnableThumbnails bool `json:"enableThumbnails"`
|
||||||
ResizePreview bool `json:"resizePreview"`
|
ResizePreview bool `json:"resizePreview"`
|
||||||
EnableExec bool `json:"enableExec"`
|
EnableExec bool `json:"enableExec"`
|
||||||
|
TypeDetectionByHeader bool `json:"typeDetectionByHeader"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean cleans any variables that might need cleaning.
|
// Clean cleans any variables that might need cleaning.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user