diff --git a/go.mod b/go.mod index bf5dbe12d..a8deff364 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e github.com/egirna/icap-client v0.1.1 - github.com/gabriel-vasile/mimetype v1.4.4 + github.com/gabriel-vasile/mimetype v1.4.5 github.com/ggwhite/go-masker v1.1.0 github.com/go-chi/chi/v5 v5.1.0 github.com/go-chi/render v1.0.3 diff --git a/go.sum b/go.sum index 19765352d..a3b36e5f6 100644 --- a/go.sum +++ b/go.sum @@ -255,8 +255,6 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU= github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE= -github.com/cs3org/reva/v2 v2.24.2-0.20240930121615-c33c803283ee h1:+1sYiuA9LRQIznBNG1AFQoIGdCUCqQT1Dof2rTTsDm8= -github.com/cs3org/reva/v2 v2.24.2-0.20240930121615-c33c803283ee/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI= github.com/cs3org/reva/v2 v2.25.0 h1:88EhLg0oQdhWxXQnvlGqlfgq3B2pVauhhPoQXrN0Wjw= github.com/cs3org/reva/v2 v2.25.0/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= @@ -337,8 +335,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I= -github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s= +github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= +github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= github.com/gdexlab/go-render v1.0.1 h1:rxqB3vo5s4n1kF0ySmoNeSPRYkEsyHgln4jFIQY7v0U= github.com/gdexlab/go-render v1.0.1/go.mod h1:wRi5nW2qfjiGj4mPukH4UV0IknS1cHD4VgFTmJX5JzM= github.com/getkin/kin-openapi v0.13.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw= diff --git a/vendor/github.com/gabriel-vasile/mimetype/README.md b/vendor/github.com/gabriel-vasile/mimetype/README.md index fd6c533e4..aa88b4bda 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/README.md +++ b/vendor/github.com/gabriel-vasile/mimetype/README.md @@ -81,7 +81,7 @@ To prevent loading entire files into memory, when detecting from a or from a [file](https://pkg.go.dev/github.com/gabriel-vasile/mimetype#DetectFile) **mimetype** limits itself to reading only the header of the input.
- structure + how project is structured
## Performance diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/json/json.go b/vendor/github.com/gabriel-vasile/mimetype/internal/json/json.go index ee39349ae..5b2ecee44 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/json/json.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/json/json.go @@ -34,6 +34,7 @@ package json import ( "fmt" + "sync" ) type ( @@ -73,10 +74,31 @@ type ( } ) +var scannerPool = sync.Pool{ + New: func() any { + return &scanner{} + }, +} + +func newScanner() *scanner { + s := scannerPool.Get().(*scanner) + s.reset() + return s +} + +func freeScanner(s *scanner) { + // Avoid hanging on to too much memory in extreme cases. + if len(s.parseState) > 1024 { + s.parseState = nil + } + scannerPool.Put(s) +} + // Scan returns the number of bytes scanned and if there was any error // in trying to reach the end of data. func Scan(data []byte) (int, error) { - s := &scanner{} + s := newScanner() + defer freeScanner(s) _ = checkValid(data, s) return s.index, s.err } @@ -84,7 +106,6 @@ func Scan(data []byte) (int, error) { // checkValid verifies that data is valid JSON-encoded data. // scan is passed in for use by checkValid to avoid an allocation. func checkValid(data []byte, scan *scanner) error { - scan.reset() for _, c := range data { scan.index++ if scan.step(scan, c) == scanError { @@ -105,6 +126,8 @@ func (s *scanner) reset() { s.step = stateBeginValue s.parseState = s.parseState[0:0] s.err = nil + s.endTop = false + s.index = 0 } // eof tells the scanner that the end of input has been reached. diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/archive.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/archive.go index 554ac4d4a..b59042c6f 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/archive.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/archive.go @@ -3,7 +3,6 @@ package magic import ( "bytes" "encoding/binary" - "strconv" ) var ( @@ -110,8 +109,8 @@ func Tar(raw []byte, _ uint32) bool { } // Get the checksum recorded into the file. - recsum, err := tarParseOctal(raw[148:156]) - if err != nil { + recsum := tarParseOctal(raw[148:156]) + if recsum == -1 { return false } sum1, sum2 := tarChksum(raw) @@ -119,28 +118,26 @@ func Tar(raw []byte, _ uint32) bool { } // tarParseOctal converts octal string to decimal int. -func tarParseOctal(b []byte) (int64, error) { +func tarParseOctal(b []byte) int64 { // Because unused fields are filled with NULs, we need to skip leading NULs. // Fields may also be padded with spaces or NULs. // So we remove leading and trailing NULs and spaces to be sure. b = bytes.Trim(b, " \x00") if len(b) == 0 { - return 0, nil + return -1 } - x, err := strconv.ParseUint(tarParseString(b), 8, 64) - if err != nil { - return 0, err + ret := int64(0) + for _, b := range b { + if b == 0 { + break + } + if !(b >= '0' && b <= '7') { + return -1 + } + ret = (ret << 3) | int64(b-'0') } - return int64(x), nil -} - -// tarParseString converts a NUL ended bytes slice to a string. -func tarParseString(b []byte) string { - if i := bytes.IndexByte(b, 0); i >= 0 { - return string(b[:i]) - } - return string(b) + return ret } // tarChksum computes the checksum for the header block b. diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/ms_office.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/ms_office.go index 5964ce596..a11801734 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/ms_office.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/ms_office.go @@ -6,41 +6,41 @@ import ( ) var ( - xlsxSigFiles = []string{ - "xl/worksheets/", - "xl/drawings/", - "xl/theme/", - "xl/_rels/", - "xl/styles.xml", - "xl/workbook.xml", - "xl/sharedStrings.xml", + xlsxSigFiles = [][]byte{ + []byte("xl/worksheets/"), + []byte("xl/drawings/"), + []byte("xl/theme/"), + []byte("xl/_rels/"), + []byte("xl/styles.xml"), + []byte("xl/workbook.xml"), + []byte("xl/sharedStrings.xml"), } - docxSigFiles = []string{ - "word/media/", - "word/_rels/document.xml.rels", - "word/document.xml", - "word/styles.xml", - "word/fontTable.xml", - "word/settings.xml", - "word/numbering.xml", - "word/header", - "word/footer", + docxSigFiles = [][]byte{ + []byte("word/media/"), + []byte("word/_rels/document.xml.rels"), + []byte("word/document.xml"), + []byte("word/styles.xml"), + []byte("word/fontTable.xml"), + []byte("word/settings.xml"), + []byte("word/numbering.xml"), + []byte("word/header"), + []byte("word/footer"), } - pptxSigFiles = []string{ - "ppt/slides/", - "ppt/media/", - "ppt/slideLayouts/", - "ppt/theme/", - "ppt/slideMasters/", - "ppt/tags/", - "ppt/notesMasters/", - "ppt/_rels/", - "ppt/handoutMasters/", - "ppt/notesSlides/", - "ppt/presentation.xml", - "ppt/tableStyles.xml", - "ppt/presProps.xml", - "ppt/viewProps.xml", + pptxSigFiles = [][]byte{ + []byte("ppt/slides/"), + []byte("ppt/media/"), + []byte("ppt/slideLayouts/"), + []byte("ppt/theme/"), + []byte("ppt/slideMasters/"), + []byte("ppt/tags/"), + []byte("ppt/notesMasters/"), + []byte("ppt/_rels/"), + []byte("ppt/handoutMasters/"), + []byte("ppt/notesSlides/"), + []byte("ppt/presentation.xml"), + []byte("ppt/tableStyles.xml"), + []byte("ppt/presProps.xml"), + []byte("ppt/viewProps.xml"), } ) diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/text.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/text.go index 9f1a637ba..cf6446397 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/text.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/text.go @@ -120,7 +120,7 @@ var ( []byte("/usr/bin/env wish"), ) // Rtf matches a Rich Text Format file. - Rtf = prefix([]byte("{\\rtf1")) + Rtf = prefix([]byte("{\\rtf")) ) // Text matches a plain text file. diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/zip.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/zip.go index dabee947b..aaa275596 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/zip.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/zip.go @@ -3,7 +3,6 @@ package magic import ( "bytes" "encoding/binary" - "strings" ) var ( @@ -43,7 +42,7 @@ func Zip(raw []byte, limit uint32) bool { // Jar matches a Java archive file. func Jar(raw []byte, limit uint32) bool { - return zipContains(raw, "META-INF/MANIFEST.MF") + return zipContains(raw, []byte("META-INF/MANIFEST.MF")) } // zipTokenizer holds the source zip file and scanned index. @@ -54,7 +53,7 @@ type zipTokenizer struct { // next returns the next file name from the zip headers. // https://web.archive.org/web/20191129114319/https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html -func (t *zipTokenizer) next() (fileName string) { +func (t *zipTokenizer) next() (fileName []byte) { if t.i > len(t.in) { return } @@ -74,15 +73,15 @@ func (t *zipTokenizer) next() (fileName string) { return } t.i += fNameOffset + fNameLen - return string(in[fNameOffset : fNameOffset+fNameLen]) + return in[fNameOffset : fNameOffset+fNameLen] } // zipContains returns true if the zip file headers from in contain any of the paths. -func zipContains(in []byte, paths ...string) bool { +func zipContains(in []byte, paths ...[]byte) bool { t := zipTokenizer{in: in} - for i, tok := 0, t.next(); tok != ""; i, tok = i+1, t.next() { + for tok := t.next(); len(tok) != 0; tok = t.next() { for p := range paths { - if strings.HasPrefix(tok, paths[p]) { + if bytes.HasPrefix(tok, paths[p]) { return true } } diff --git a/vendor/github.com/gabriel-vasile/mimetype/mimetype.gif b/vendor/github.com/gabriel-vasile/mimetype/mimetype.gif deleted file mode 100644 index c3e808767..000000000 Binary files a/vendor/github.com/gabriel-vasile/mimetype/mimetype.gif and /dev/null differ diff --git a/vendor/github.com/gabriel-vasile/mimetype/supported_mimes.md b/vendor/github.com/gabriel-vasile/mimetype/supported_mimes.md index 5ec6f6b65..0a24ba386 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/supported_mimes.md +++ b/vendor/github.com/gabriel-vasile/mimetype/supported_mimes.md @@ -167,7 +167,7 @@ Extension | MIME type | Aliases **.geojson** | application/geo+json | - **.har** | application/json | - **.ndjson** | application/x-ndjson | - -**.rtf** | text/rtf | - +**.rtf** | text/rtf | application/rtf **.srt** | application/x-subrip | application/x-srt, text/x-srt **.tcl** | text/x-tcl | application/x-tcl **.csv** | text/csv | - diff --git a/vendor/github.com/gabriel-vasile/mimetype/tree.go b/vendor/github.com/gabriel-vasile/mimetype/tree.go index 253bd0064..75dcd7b1b 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/tree.go +++ b/vendor/github.com/gabriel-vasile/mimetype/tree.go @@ -86,7 +86,7 @@ var ( ndJSON = newMIME("application/x-ndjson", ".ndjson", magic.NdJSON) html = newMIME("text/html", ".html", magic.HTML) php = newMIME("text/x-php", ".php", magic.Php) - rtf = newMIME("text/rtf", ".rtf", magic.Rtf) + rtf = newMIME("text/rtf", ".rtf", magic.Rtf).alias("application/rtf") js = newMIME("application/javascript", ".js", magic.Js). alias("application/x-javascript", "text/javascript") srt = newMIME("application/x-subrip", ".srt", magic.Srt). diff --git a/vendor/modules.txt b/vendor/modules.txt index 902deef83..bbaa7b2a8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -809,7 +809,7 @@ github.com/felixge/httpsnoop # github.com/fsnotify/fsnotify v1.7.0 ## explicit; go 1.17 github.com/fsnotify/fsnotify -# github.com/gabriel-vasile/mimetype v1.4.4 +# github.com/gabriel-vasile/mimetype v1.4.5 ## explicit; go 1.20 github.com/gabriel-vasile/mimetype github.com/gabriel-vasile/mimetype/internal/charset