Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ianlancetaylor committed Apr 13, 2021
1 parent 39dd96c commit 7b19fb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/mime/testdata/test.types.globs2
Expand Up @@ -6,3 +6,4 @@
# mime package test for globs2
50:document/test:*.t3
50:example/test:*.t4
30:example/do-not-use:*.t4
10 changes: 9 additions & 1 deletion src/mime/type_unix.go
Expand Up @@ -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)
Expand Down

0 comments on commit 7b19fb1

Please sign in to comment.