]> Cypherpunks.ru repositories - gostls13.git/commitdiff
path/filepath: change IsAbs to treat \\host\share as an absolute path
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Thu, 15 Jul 2021 14:53:47 +0000 (23:53 +0900)
committerAlex Brainman <alex.brainman@gmail.com>
Wed, 18 Aug 2021 08:26:44 +0000 (08:26 +0000)
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>
src/path/filepath/path_test.go
src/path/filepath/path_windows.go

index bc5509b49cf1ab7e4820405a10a869d9b56edd61..55b27f1af88928df36c993dd28d500105676a35c 100644 (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},
 }
index 445c868e41460456469d1459d868352fdaa3e5c2..b4d8ac33010e753bf158f3c7f550995e52c7e5e1 100644 (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