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 {
81
81
return strings .SplitN (ct .contentType , ";" , 2 )[0 ]
82
82
}
83
83
84
- var svgCloseTag = []byte ("</svg>" )
85
-
86
84
// DetectContentType extends http.DetectContentType with more content types. Defaults to text/unknown if input is empty.
87
85
func DetectContentType (data []byte ) SniffedType {
88
86
if len (data ) == 0 {
@@ -102,11 +100,9 @@ func DetectContentType(data []byte) SniffedType {
102
100
if detectByHTML || detectByXML {
103
101
dataProcessed := svgComment .ReplaceAll (data , nil )
104
102
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
110
106
}
111
107
}
112
108
Original file line number Diff line number Diff line change @@ -68,9 +68,6 @@ func TestIsSvgImage(t *testing.T) {
68
68
<!-- <svg></svg> inside comment -->
69
69
<foo></foo>` )).IsSvgImage ())
70
70
71
- assert .False (t , DetectContentType ([]byte (`<svg></svg><span></span>` )).IsSvgImage ())
72
- assert .False (t , DetectContentType ([]byte (`<svg></svg>text` )).IsSvgImage ())
73
-
74
71
assert .False (t , DetectContentType ([]byte (`
75
72
<!-- comment1 -->
76
73
<div>
You can’t perform that action at this time.
0 commit comments