path/filepath: change IsAbs to treat \\host\share as an absolute path

Fixes #47123

Change-Id: I2226b8a9ea24cd88171acfbaffea2566309416de
Reviewed-on: https://go-review.googlesource.com/c/go/+/334809
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
Yasuhiro Matsumoto 2021-07-15 23:53:47 +09:00 committed by Alex Brainman
parent 946e2543f8
commit 8b471db71b
2 changed files with 6 additions and 0 deletions

View file

@ -791,6 +791,8 @@ var winisabstests = []IsAbsTest{
{`c:a\b`, false},
{`c:\a\b`, true},
{`c:/a/b`, true},
{`\\host\share`, true},
{`\\host\share\`, true},
{`\\host\share\foo`, true},
{`//host/share/foo/bar`, true},
}

View file

@ -45,6 +45,10 @@ func IsAbs(path string) (b bool) {
if l == 0 {
return false
}
// If the volume name starts with a double slash, this is a UNC path.
if isSlash(path[0]) && isSlash(path[1]) {
return true
}
path = path[l:]
if path == "" {
return false