]> Sergey Matveev's repositories - tofuproxy.git/blobdiff - main.go
Fonts restriction
[tofuproxy.git] / main.go
diff --git a/main.go b/main.go
index 4464fead426d585bbc1fc6a763d280f85229b7ea..16fae3d6c0742f5ab38723ce1dfa4ae6f704cf35 100644 (file)
--- a/main.go
+++ b/main.go
@@ -152,6 +152,22 @@ func roundTrip(w http.ResponseWriter, req *http.Request) {
                w.Write([]byte(err.Error()))
                return
        }
+       contentType := resp.Header.Get("Content-Type")
+       switch contentType {
+       case "application/font-woff", "application/font-sfnt":
+               // Those are deprecated types
+               fallthrough
+       case "font/otf", "font/ttf", "font/woff", "font/woff2":
+               http.NotFound(w, req)
+               sinkOther <- fmt.Sprintf(
+                       "%s %s\t%d\tfonts are not allowed",
+                       req.Method,
+                       req.URL.String(),
+                       http.StatusNotFound,
+               )
+               resp.Body.Close()
+               return
+       }
        for k, vs := range resp.Header {
                if k == "Location" || k == "Content-Type" || k == "Content-Length" {
                        continue