mirror of
https://github.com/golang/go
synced 2024-11-24 09:00:13 -07:00
mime: short circuit short globs2 glob exclusion
Applied on top of previous changes, this will only exclude the hypothetical *. which is unlikely to be in globs2 files out there. But because we're checking for the length anyway, we might as well bump the minimum length to 3 (includes * and .) to short circuit exclusion of too short entries.
This commit is contained in:
parent
1a4c16854e
commit
ee55edcf08
@ -42,7 +42,7 @@ func loadMimeGlobsFile(filename string) error {
|
|||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
// Each line should be of format: weight:mimetype:*.ext[:morefields...]
|
// Each line should be of format: weight:mimetype:*.ext[:morefields...]
|
||||||
fields := strings.Split(scanner.Text(), ":")
|
fields := strings.Split(scanner.Text(), ":")
|
||||||
if len(fields) < 3 || len(fields[0]) < 1 || len(fields[2]) < 2 {
|
if len(fields) < 3 || len(fields[0]) < 1 || len(fields[2]) < 3 {
|
||||||
continue
|
continue
|
||||||
} else if fields[0][0] == '#' || fields[2][0] != '*' || fields[2][1] != '.' {
|
} else if fields[0][0] == '#' || fields[2][0] != '*' || fields[2][1] != '.' {
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user