From 7a1292b58b2a20966054ad09504a022367c31728 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 3 Jun 2025 19:01:18 -0300 Subject: [PATCH] handle files declared as .apk as .apk. --- khatru/blossom/handlers.go | 5 +++++ khatru/blossom/utils.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/khatru/blossom/handlers.go b/khatru/blossom/handlers.go index dcf6d12..a36b011 100644 --- a/khatru/blossom/handlers.go +++ b/khatru/blossom/handlers.go @@ -91,6 +91,11 @@ func (bs BlossomServer) handleUpload(w http.ResponseWriter, r *http.Request) { ext = getExtension(mimetype) } + // special case of android apk -- if we see a .zip but they say it's .apk we trust them + if ext == ".zip" && getExtension(r.Header.Get("Content-Type")) == ".apk" { + ext = ".apk" + } + // run the reject hooks if nil != bs.RejectUpload { reject, reason, code := bs.RejectUpload(r.Context(), auth, size, ext) diff --git a/khatru/blossom/utils.go b/khatru/blossom/utils.go index 47d8ee5..6de47b3 100644 --- a/khatru/blossom/utils.go +++ b/khatru/blossom/utils.go @@ -26,6 +26,8 @@ func getExtension(mimetype string) string { return ".webp" case "video/mp4": return ".mp4" + case "application/vnd.android.package-archive": + return ".apk" } exts, _ := mime.ExtensionsByType(mimetype)