From f051ca3b3fb7c852d844f0140c451c94f03de8ed Mon Sep 17 00:00:00 2001 From: k8s-infra-cherrypick-robot <90416843+k8s-infra-cherrypick-robot@users.noreply.github.com> Date: Sat, 22 Mar 2025 03:40:31 -0700 Subject: [PATCH] Custom Error Pages: Accept first of many MIME types. (#13006) Co-authored-by: Jeremy Ebler --- images/custom-error-pages/rootfs/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/images/custom-error-pages/rootfs/main.go b/images/custom-error-pages/rootfs/main.go index 7d3d73029..4228a7214 100644 --- a/images/custom-error-pages/rootfs/main.go +++ b/images/custom-error-pages/rootfs/main.go @@ -126,6 +126,12 @@ func errorHandler(path, defaultFormat string) func(http.ResponseWriter, *http.Re log.Printf("format not specified. Using %v", format) } + // if multiple formats are provided, use the first one + index := strings.Index(format, ",") + if index != -1 { + format = format[:index] + } + cext, err := mime.ExtensionsByType(format) if err != nil { log.Printf("unexpected error reading media type extension: %v. Using %v", err, ext)