all repos — honk @ 118ae706524ef58ea5074b19811e3c0fa9411a59

my fork of honk

why can't svg just be normal?
Ted Unangst tedu@tedunangst.com
Thu, 07 Dec 2023 18:19:39 -0500
commit

118ae706524ef58ea5074b19811e3c0fa9411a59

parent

62cc237963d9123fe9db364c30e30ed45f20e833

1 files changed, 10 insertions(+), 2 deletions(-)

jump to
M backend.gobackend.go

@@ -69,8 +69,16 @@ data = data[3:]

} ct := http.DetectContentType(data) if strings.HasPrefix(ct, "text/xml") || strings.HasPrefix(ct, "text/plain") { - if bytes.HasPrefix(data, []byte("<svg ")) || bytes.HasPrefix(data, []byte("<!DOCTYPE svg PUBLIC")) { - return true + // this seems suboptimal + prefixes := []string{ + `<svg `, + `<!DOCTYPE svg PUBLIC`, + `<?xml version="1.0" encoding="UTF-8"?> <svg `, + } + for _, pre := range prefixes { + if bytes.HasPrefix(data, []byte(pre)) { + return true + } } } return ct == "image/svg+xml"