diff --git a/imagemeta/image_meta.go b/imagemeta/image_meta.go index 1acc2375..d7770158 100644 --- a/imagemeta/image_meta.go +++ b/imagemeta/image_meta.go @@ -93,9 +93,7 @@ func DecodeMeta(r io.Reader) (Meta, error) { } } - if ok, err := IsSVG(rr); err != nil { - return nil, err - } else if ok { + if IsSVG(rr) { return &meta{format: imagetype.SVG, width: 1, height: 1}, nil } diff --git a/imagemeta/svg.go b/imagemeta/svg.go index bdba0b7f..571f5f86 100644 --- a/imagemeta/svg.go +++ b/imagemeta/svg.go @@ -10,7 +10,7 @@ import ( "github.com/tdewolff/parse/v2/xml" ) -func IsSVG(r io.Reader) (bool, error) { +func IsSVG(r io.Reader) bool { maxBytes := config.MaxSvgCheckBytes l := xml.NewLexer(parse.NewInput(io.LimitReader(r, int64(maxBytes)))) @@ -20,13 +20,10 @@ func IsSVG(r io.Reader) (bool, error) { switch tt { case xml.ErrorToken: - if err := l.Err(); err != io.EOF { - return false, err - } - return false, nil + return false case xml.StartTagToken: - return strings.ToLower(string(l.Text())) == "svg", nil + return strings.ToLower(string(l.Text())) == "svg" } } }