aboutsummaryrefslogtreecommitdiff
path: root/src/path
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2021-07-15 23:53:47 +0900
committerAlex Brainman <alex.brainman@gmail.com>2021-08-18 08:26:44 +0000
commit8b471db71b95e9250f751f494a6a5359cb50d5cd (patch)
tree2ae34c61660f77a3e574535f1b6ab1c00f9ed2ae /src/path
parent946e2543f878929752da9d16575dd5e96ac78532 (diff)
downloadgo-8b471db71b95e9250f751f494a6a5359cb50d5cd.tar.gz
go-8b471db71b95e9250f751f494a6a5359cb50d5cd.zip
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>
Diffstat (limited to 'src/path')
-rw-r--r--src/path/filepath/path_test.go2
-rw-r--r--src/path/filepath/path_windows.go4
2 files changed, 6 insertions, 0 deletions
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