aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath/path_windows_test.go
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2022-04-22 10:07:51 +0900
committerGopher Robot <gobot@golang.org>2022-05-24 21:52:14 +0000
commit9cd1818a7d019c02fa4898b3e45a323e35033290 (patch)
tree582a5c871a2371794f242fce0310a2ebd4f6aabb /src/path/filepath/path_windows_test.go
parentb6bcd0d1352578033eea0490790b6af3bf300b3f (diff)
downloadgo-9cd1818a7d019c02fa4898b3e45a323e35033290.tar.xz
path/filepath: do not remove prefix "." when following path contains ":".
Fixes #52476 Change-Id: I9eb72ac7dbccd6322d060291f31831dc389eb9bb Reviewed-on: https://go-review.googlesource.com/c/go/+/401595 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/path/filepath/path_windows_test.go')
-rw-r--r--src/path/filepath/path_windows_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go
index 37019210fa..9e6c0ec81d 100644
--- a/src/path/filepath/path_windows_test.go
+++ b/src/path/filepath/path_windows_test.go
@@ -534,3 +534,29 @@ func TestNTNamespaceSymlink(t *testing.T) {
t.Errorf(`EvalSymlinks(%q): got %q, want %q`, filelink, got, want)
}
}
+
+func TestIssue52476(t *testing.T) {
+ tests := []struct {
+ lhs, rhs string
+ want string
+ }{
+ {`..\.`, `C:`, `..\C:`},
+ {`..`, `C:`, `..\C:`},
+ {`.`, `:`, `:`},
+ {`.`, `C:`, `.\C:`},
+ {`.`, `C:/a/b/../c`, `.\C:\a\c`},
+ {`.`, `\C:`, `.\C:`},
+ {`C:\`, `.`, `C:\`},
+ {`C:\`, `C:\`, `C:\C:`},
+ {`C`, `:`, `C\:`},
+ {`\.`, `C:`, `\C:`},
+ {`\`, `C:`, `\C:`},
+ }
+
+ for _, test := range tests {
+ got := filepath.Join(test.lhs, test.rhs)
+ if got != test.want {
+ t.Errorf(`Join(%q, %q): got %q, want %q`, test.lhs, test.rhs, got, test.want)
+ }
+ }
+}