aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/filetype_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/filetype_test.go')
-rw-r--r--internal/web/filetype_test.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/web/filetype_test.go b/internal/web/filetype_test.go
index 1f1d89e..45c4166 100644
--- a/internal/web/filetype_test.go
+++ b/internal/web/filetype_test.go
@@ -35,8 +35,14 @@ func TestFileType(t *testing.T) {
{"hello world", "notes.txt", "text/plain", "document"},
{"hello world", "server.log", "text/plain", "document"}, // text/* names only confirm the sniff
{"hello world", "notes.md", "text/plain", "document"},
- {"hello world", "README", "text/plain", "document"}, // no extension: the bytes are all we have
- {"\x00\x01\x02\x03\xff\xfe", "font.ttf", "application/octet-stream", "other"},
+ {"hello world", "README", "text/plain", "document"}, // no extension: the bytes are all we have
+ {"\x00\x01\x02\x03\xff\xfe", "font.ttf", "application/octet-stream", "other"}, // a font is known by its bytes
+ {"wOF2\x00\x01\x00\x00", "body.woff2", "font/woff2", "font"},
+ {"wOFF\x00\x01\x00\x00", "body.woff", "font/woff", "font"},
+ {"\x00\x01\x00\x00\x00\x10", "body.ttf", "font/ttf", "font"},
+ {"OTTO\x00\x10\x00\x80", "body.otf", "font/otf", "font"},
+ {"OTTO\x00\x10\x00\x80", "evil.html", "font/otf", "font"},
+ {"ttcf\x00\x01\x00\x00", "family.ttc", "application/octet-stream", "other"},
{"hello world", "data.csv", "text/csv", "document"},
{"hello world", "evil.html", "application/octet-stream", "other"},
{"<svg xmlns='http://www.w3.org/2000/svg'><script>1</script></svg>", "evil.svg", "application/octet-stream", "other"},
@@ -69,6 +75,7 @@ func TestServedAs(t *testing.T) {
{"text/plain", false, "text/plain; charset=utf-8", "inline"},
{"audio/mpeg", false, "audio/mpeg", "inline"},
{"video/mp4", false, "video/mp4", "inline"},
+ {"font/woff2", false, "font/woff2", "inline"},
{"application/zip", false, "application/octet-stream", "attachment"},
{"text/html", false, "application/octet-stream", "attachment"},
{"image/svg+xml", false, "application/octet-stream", "attachment"},