]> Cypherpunks repositories - gostls13.git/commit
io/fs, path, path/filepath, testing/fstest: validate patterns in Match, Glob
authorRuss Cox <rsc@golang.org>
Thu, 22 Oct 2020 16:11:29 +0000 (12:11 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 23 Oct 2020 14:59:03 +0000 (14:59 +0000)
commitb5ddc42b465dd5b9532ee336d98343d81a6d35b2
treed3ea8f2fe5c41f4befebaeda5600832839b0bbbb
parent4a2cc73f8789e3df43c1c96944c90f55757a23b0
io/fs, path, path/filepath, testing/fstest: validate patterns in Match, Glob

According to #28614, proposal review agreed in December 2018 that
Match should return an error for failed matches where the unmatched
part of the pattern has a syntax error. (The failed match has to date
caused the scan of the pattern to stop early.)

This change implements that behavior: the match loop continues
scanning to the end of the pattern, even after a confirmed mismatch,
to check whether the pattern is even well-formed.

The change applies to both path.Match and filepath.Match.
Then filepath.Glob and fs.Glob make a single validity-checking
call to Match before beginning their usual processing.

Also update fstest.TestFS to check for correct validation in custom
Glob implementations.

Fixes #28614.

Change-Id: Ic1d35a4bb9c3565184ae83dbefc425c5c96318e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/264397
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/io/fs/glob.go
src/io/fs/glob_test.go
src/path/filepath/match.go
src/path/filepath/match_test.go
src/path/match.go
src/path/match_test.go
src/testing/fstest/testfs.go