File tree Expand file tree Collapse file tree 2 files changed +3
-10
lines changed Expand file tree Collapse file tree 2 files changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,6 @@ func (ct SniffedType) GetMimeType() string {
8181 return strings .SplitN (ct .contentType , ";" , 2 )[0 ]
8282}
8383
84- var svgCloseTag = []byte ("</svg>" )
85-
8684// DetectContentType extends http.DetectContentType with more content types. Defaults to text/unknown if input is empty.
8785func DetectContentType (data []byte ) SniffedType {
8886 if len (data ) == 0 {
@@ -102,11 +100,9 @@ func DetectContentType(data []byte) SniffedType {
102100 if detectByHTML || detectByXML {
103101 dataProcessed := svgComment .ReplaceAll (data , nil )
104102 dataProcessed = bytes .TrimSpace (dataProcessed )
105- if bytes .HasSuffix (dataProcessed , svgCloseTag ) {
106- if detectByHTML && svgTagRegex .Match (dataProcessed ) ||
107- detectByXML && svgTagInXMLRegex .Match (dataProcessed ) {
108- ct = SvgMimeType
109- }
103+ if detectByHTML && svgTagRegex .Match (dataProcessed ) ||
104+ detectByXML && svgTagInXMLRegex .Match (dataProcessed ) {
105+ ct = SvgMimeType
110106 }
111107 }
112108
Original file line number Diff line number Diff line change @@ -68,9 +68,6 @@ func TestIsSvgImage(t *testing.T) {
6868 <!-- <svg></svg> inside comment -->
6969 <foo></foo>` )).IsSvgImage ())
7070
71- assert .False (t , DetectContentType ([]byte (`<svg></svg><span></span>` )).IsSvgImage ())
72- assert .False (t , DetectContentType ([]byte (`<svg></svg>text` )).IsSvgImage ())
73-
7471 assert .False (t , DetectContentType ([]byte (`
7572<!-- comment1 -->
7673<div>
You can’t perform that action at this time.
0 commit comments