From c7fdd04e886574ec03309caabe57b07073e95389 Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Tue, 2 Apr 2024 14:57:51 +0200 Subject: [PATCH] add secret force upload function --- go/main.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/go/main.go b/go/main.go index adc530f..12939e0 100644 --- a/go/main.go +++ b/go/main.go @@ -105,11 +105,14 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { return } - mimeType := http.DetectContentType(buffer) - if !strings.HasPrefix(mimeType, "image/") && !strings.HasPrefix(mimeType, "text/xml") && !strings.HasPrefix(mimeType, "image/svg+xml") { - http.Error(w, "Nur Bild-Uploads sind erlaubt", http.StatusBadRequest) - log.Printf("Versuch, eine Nicht-Bild-Datei hochzuladen: %v", mimeType) - return + forceUpload := r.FormValue("force_upload") + if forceUpload != "true" { + mimeType := http.DetectContentType(buffer) + if !strings.HasPrefix(mimeType, "image/") && !strings.HasPrefix(mimeType, "text/xml") && !strings.HasPrefix(mimeType, "image/svg+xml") { + http.Error(w, "Nur Bild-Uploads sind erlaubt", http.StatusBadRequest) + log.Printf("Versuch, eine Nicht-Bild-Datei hochzuladen: %v", mimeType) + return + } } _, err = file.Seek(0, io.SeekStart)