mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 08:42:32 -05:00
Merge pull request '[GITEA] Recognize OGG as an audio format' (#1093) from Gusted/forgejo:forgejo-ogg into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/1093
This commit is contained in:
commit
4f46908965
2 changed files with 3 additions and 1 deletions
|
@ -62,7 +62,7 @@ func (ct SniffedType) IsVideo() bool {
|
||||||
|
|
||||||
// IsAudio detects if data is an video format
|
// IsAudio detects if data is an video format
|
||||||
func (ct SniffedType) IsAudio() bool {
|
func (ct SniffedType) IsAudio() bool {
|
||||||
return strings.Contains(ct.contentType, "audio/")
|
return strings.Contains(ct.contentType, "audio/") || strings.Contains(ct.contentType, "application/ogg")
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRepresentableAsText returns true if file content can be represented as
|
// IsRepresentableAsText returns true if file content can be represented as
|
||||||
|
|
|
@ -113,6 +113,8 @@ func TestIsAudio(t *testing.T) {
|
||||||
assert.True(t, DetectContentType([]byte("ID3Toy\000")).IsAudio())
|
assert.True(t, DetectContentType([]byte("ID3Toy\000")).IsAudio())
|
||||||
assert.True(t, DetectContentType([]byte("ID3Toy\n====\t* hi 🌞, ...")).IsText()) // test ID3 tag for plain text
|
assert.True(t, DetectContentType([]byte("ID3Toy\n====\t* hi 🌞, ...")).IsText()) // test ID3 tag for plain text
|
||||||
assert.True(t, DetectContentType([]byte("ID3Toy\n====\t* hi 🌞, ..."+"🌛"[0:2])).IsText()) // test ID3 tag with incomplete UTF8 char
|
assert.True(t, DetectContentType([]byte("ID3Toy\n====\t* hi 🌞, ..."+"🌛"[0:2])).IsText()) // test ID3 tag with incomplete UTF8 char
|
||||||
|
|
||||||
|
assert.True(t, DetectContentType([]byte("OggS\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x7e\x46\x00\x00\x00\x00\x00\x00\x1f\xf6\xb4\xfc\x01\x1e\x01\x76\x6f\x72")).IsAudio()) // application/ogg
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDetectContentTypeFromReader(t *testing.T) {
|
func TestDetectContentTypeFromReader(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue