]> Cypherpunks.ru repositories - gostls13.git/commit
io/fs: allow backslash in ValidPath, reject in os.DirFS.Open
authorRuss Cox <rsc@golang.org>
Tue, 9 Feb 2021 18:46:53 +0000 (13:46 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 11 Feb 2021 01:10:28 +0000 (01:10 +0000)
commite5b08e6d5cecb646066c0cadddf6300e2a10ffb2
tree74c7b56d1c89924544a37c36eb93ddd2fd40b539
parented8079096fe2e78d6dcb8002758774dca6d24eee
io/fs: allow backslash in ValidPath, reject in os.DirFS.Open

Rejecting backslash introduces problems with presenting
underlying OS file systems that contain names with backslash.
Rejecting backslash also does not Windows-proof the syntax,
because colon can also be a path separator. And we are not
going to reject colon from all names. So don't reject backslash
either.

There is a similar problem on Windows with names containing
slashes, but those are more difficult (though not impossible)
to create.

Also document and enforce that paths must be UTF-8.

Fixes #44166.

Change-Id: Iac7a9a268025c1fd31010dbaf3f51e1660c7ae2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/290709
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
src/io/fs/fs.go
src/io/fs/fs_test.go
src/os/file.go
src/os/os_test.go