From: Yasuhiro Matsumoto Date: Thu, 15 Jul 2021 14:53:47 +0000 (+0900) Subject: path/filepath: change IsAbs to treat \\host\share as an absolute path X-Git-Tag: go1.18beta1~1720 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8b471db71b;p=gostls13.git 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 Trust: Hajime Hoshi Reviewed-by: Alex Brainman --- diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index bc5509b49c..55b27f1af8 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -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}, } diff --git a/src/path/filepath/path_windows.go b/src/path/filepath/path_windows.go index 445c868e41..b4d8ac3301 100644 --- a/src/path/filepath/path_windows.go +++ b/src/path/filepath/path_windows.go @@ -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