aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath/path_test.go
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2018-10-21 14:57:58 +1100
committerAlex Brainman <alex.brainman@gmail.com>2018-11-02 07:24:50 +0000
commitd154ef60a0c88be98c70bbe1c5735fb7b1f45250 (patch)
treece4550c7a6ee275606f10f3474afc6a576a2a83a /src/path/filepath/path_test.go
parenta70a2a8ad69f481d5fcaf9e006e224fbab7df754 (diff)
downloadgo-d154ef60a0c88be98c70bbe1c5735fb7b1f45250.tar.xz
path/filepath: change IsAbs("NUL") to return true
This CL changes IsAbs to return true for "NUL" and other Windows reserved filenames (search https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file for NUL for details). os.Open("NUL") and os.Stat("NUL") work regardless of what current directory is, and it is mistake to join "NUL" with current directory when building full path. Changing IsAbs("NUL") to return true fixes that mistake. Fixes #28035 Change-Id: Ife8f8aee48400702613ede8fc6834fd43e6e0f03 Reviewed-on: https://go-review.googlesource.com/c/145220 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/path/filepath/path_test.go')
-rw-r--r--src/path/filepath/path_test.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
index eddae4755b..3434ea2e6e 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -751,6 +751,11 @@ func TestIsAbs(t *testing.T) {
for _, test := range isabstests {
tests = append(tests, IsAbsTest{"c:" + test.path, test.isAbs})
}
+ // Test reserved names.
+ tests = append(tests, IsAbsTest{os.DevNull, true})
+ tests = append(tests, IsAbsTest{"NUL", true})
+ tests = append(tests, IsAbsTest{"nul", true})
+ tests = append(tests, IsAbsTest{"CON", true})
} else {
tests = isabstests
}