Compare commits

..

No commits in common. "4bdb8dd9cc028a071819afd8f79cf29b30ab4d30" and "f1c5d33d3e8ec3dc5988c130b6899cffe6b0e651" have entirely different histories.

4 changed files with 2 additions and 32 deletions

View File

@ -71,7 +71,7 @@ func (ct SniffedType) IsRepresentableAsText() bool {
return ct.IsText() || ct.IsSvgImage()
}
// IsBrowsableBinaryType returns whether a non-text type can be displayed in a browser
// IsBrowsableType returns whether a non-text type can be displayed in a browser
func (ct SniffedType) IsBrowsableBinaryType() bool {
return ct.IsImage() || ct.IsSvgImage() || ct.IsPDF() || ct.IsVideo() || ct.IsAudio()
}
@ -116,17 +116,6 @@ func DetectContentType(data []byte) SniffedType {
}
}
if ct == "application/ogg" {
dataHead := data
if len(dataHead) > 256 {
dataHead = dataHead[:256] // only need to do a quick check for the file header
}
if bytes.Contains(dataHead, []byte("theora")) || bytes.Contains(dataHead, []byte("dirac")) {
ct = "video/ogg" // ogg is only used for some video formats, and it's not popular
} else {
ct = "audio/ogg" // for most cases, it is used as an audio container
}
}
return SniffedType{ct}
}

View File

@ -6,7 +6,6 @@ package typesniffer
import (
"bytes"
"encoding/base64"
"encoding/hex"
"strings"
"testing"
@ -122,15 +121,3 @@ func TestDetectContentTypeFromReader(t *testing.T) {
assert.NoError(t, err)
assert.True(t, st.IsAudio())
}
func TestDetectContentTypeOgg(t *testing.T) {
oggAudio, _ := hex.DecodeString("4f67675300020000000000000000352f0000000000007dc39163011e01766f72626973000000000244ac0000000000000071020000000000b8014f6767530000")
st, err := DetectContentTypeFromReader(bytes.NewReader(oggAudio))
assert.NoError(t, err)
assert.True(t, st.IsAudio())
oggVideo, _ := hex.DecodeString("4f676753000200000000000000007d9747ef000000009b59daf3012a807468656f7261030201001e00110001e000010e00020000001e00000001000001000001")
st, err = DetectContentTypeFromReader(bytes.NewReader(oggVideo))
assert.NoError(t, err)
assert.True(t, st.IsVideo())
}

View File

@ -56,7 +56,7 @@ func (p *AuthSourceProvider) DisplayName() string {
func (p *AuthSourceProvider) IconHTML() template.HTML {
if p.iconURL != "" {
img := fmt.Sprintf(`<img class="gt-object-contain gt-mr-3" width="20" height="20" src="%s" alt="%s">`,
img := fmt.Sprintf(`<img class="gt-mr-3" width="20" height="20" src="%s" alt="%s">`,
html.EscapeString(p.iconURL), html.EscapeString(p.DisplayName()),
)
return template.HTML(img)

View File

@ -51,9 +51,3 @@
.dropzone .dz-preview:hover .dz-image img {
filter: opacity(0.5) !important;
}
.ui .field .dropzone .dz-preview .dz-progress {
/* by default the progress-bar is vertically centered (top: 50%), it's better to put it after the "details (size, filename)",
then the layout from top to bottom is: size, filename, progress */
top: 7em;
}