From de76daee9cdd3cf8a1268efcabcc29c0adf6e8cc Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Tue, 27 Sep 2016 22:21:59 +0100 Subject: [PATCH] fix(type): svg type checking --- type.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/type.go b/type.go index 889fdc7..3356af5 100644 --- a/type.go +++ b/type.go @@ -30,8 +30,8 @@ const ( type ImageType int var ( - htmlCommentRegex = regexp.MustCompile("") - svgRegex = regexp.MustCompile(`^\s*(?:<\?xml[^>]*>\s*)?(?:]*>\s*)?]*>[^*]*<\/svg>\s*$`) + htmlCommentRegex = regexp.MustCompile("(?i)") + svgRegex = regexp.MustCompile(`(?i)^\s*(?:<\?xml[^>]*>\s*)?(?:]*>\s*)?]*>[^*]*<\/svg>\s*$`) ) // ImageTypes stores as pairs of image types supported and its alias names. @@ -75,7 +75,7 @@ func isBinary(buf []byte) bool { // IsSVGImage returns true if the given buffer is a valid SVG image. func IsSVGImage(buf []byte) bool { - return !isBinary(buf) && svgRegex.Match(htmlCommentRegex.ReplaceAll(buf, []byte{0})) + return !isBinary(buf) && svgRegex.Match(htmlCommentRegex.ReplaceAll(buf, []byte{})) } // DetermineImageType determines the image type format (jpeg, png, webp or tiff)