aboutsummaryrefslogtreecommitdiff
path: root/src/mime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-04-12 22:26:37 -0700
committerIan Lance Taylor <iant@golang.org>2021-04-13 18:08:06 +0000
commit7b19fb1d560908a848e07e091fb5df61f4848389 (patch)
tree17b51820e26685ba910fee6f1fd59353c8ab0ac2 /src/mime
parent39dd96ca5a60502d66494bff83257379df660eea (diff)
downloadgo-7b19fb1d560908a848e07e091fb5df61f4848389.tar.gz
go-7b19fb1d560908a848e07e091fb5df61f4848389.zip
mime: in globs2 file only keep first time extension is seen
Fixes #45534 Change-Id: I9855607e845951f26ab85cb179ec6dea40d92156 Reviewed-on: https://go-review.googlesource.com/c/go/+/309574 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/mime')
-rw-r--r--src/mime/testdata/test.types.globs21
-rw-r--r--src/mime/type_unix.go10
2 files changed, 10 insertions, 1 deletions
diff --git a/src/mime/testdata/test.types.globs2 b/src/mime/testdata/test.types.globs2
index 2e893262ea..cb5b7899b0 100644
--- a/src/mime/testdata/test.types.globs2
+++ b/src/mime/testdata/test.types.globs2
@@ -6,3 +6,4 @@
# mime package test for globs2
50:document/test:*.t3
50:example/test:*.t4
+30:example/do-not-use:*.t4
diff --git a/src/mime/type_unix.go b/src/mime/type_unix.go
index 59c99e2c86..f954bc8a1f 100644
--- a/src/mime/type_unix.go
+++ b/src/mime/type_unix.go
@@ -49,7 +49,15 @@ func loadMimeGlobsFile(filename string) error {
continue
}
- setExtensionType(fields[2][1:], fields[1])
+ extension := fields[2][1:]
+ if _, ok := mimeTypes.Load(extension); ok {
+ // We've already seen this extension.
+ // The file is in weight order, so we keep
+ // the first entry that we see.
+ continue
+ }
+
+ setExtensionType(extension, fields[1])
}
if err := scanner.Err(); err != nil {
panic(err)