1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00

Don't return error from imagemeta.isSVG

This commit is contained in:
DarthSim 2022-11-28 22:38:17 +06:00
parent 3f9a0641f1
commit c105e66e39
2 changed files with 4 additions and 9 deletions

View File

@ -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
}

View File

@ -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"
}
}
}