Skip to content

Commit 409ad49

Browse files
committed
remove the close tag check
1 parent b741a0a commit 409ad49

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

modules/typesniffer/typesniffer.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff 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.
8785
func 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

modules/typesniffer/typesniffer_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)