aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2022-12-01 21:59:00 +0100
committerQuim Muntal <quimmuntal@gmail.com>2023-01-24 07:42:17 +0000
commit030ca34f5786f0b924dcab26379ee2f82104220d (patch)
tree641f66bf22dc4a05277fe744ef5aa12b8981c156
parent7135710e01ab86468f23ac412e7f03f49235d5bb (diff)
downloadgo-030ca34f5786f0b924dcab26379ee2f82104220d.tar.xz
path/filepath: remove extra Clean call in EvalSymlinks on Windows
EvalSymlinks calls Clean twice, one in walkSymlinks and another in toNorm. The later is not necessary, as toNorm is only called by EvalSymlinks and just after walkSymlinks cleans the path without any path manipulation in between. Change-Id: Ibdb782c7eed59468f0ebb913e98d2a7db0df010d Reviewed-on: https://go-review.googlesource.com/c/go/+/454615 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
-rw-r--r--src/path/filepath/path_windows_test.go10
-rw-r--r--src/path/filepath/symlink_windows.go2
2 files changed, 8 insertions, 4 deletions
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go
index e37dddcead..8553485a2d 100644
--- a/src/path/filepath/path_windows_test.go
+++ b/src/path/filepath/path_windows_test.go
@@ -347,7 +347,11 @@ func TestToNorm(t *testing.T) {
}
for _, test := range tests {
- got, err := filepath.ToNorm(test.arg, stubBase)
+ var path string
+ if test.arg != "" {
+ path = filepath.Clean(test.arg)
+ }
+ got, err := filepath.ToNorm(path, stubBase)
if err != nil {
t.Errorf("toNorm(%s) failed: %v\n", test.arg, err)
} else if got != test.want {
@@ -439,7 +443,9 @@ func TestToNorm(t *testing.T) {
continue
}
}
-
+ if arg != "" {
+ arg = filepath.Clean(arg)
+ }
got, err := filepath.ToNorm(arg, filepath.NormBase)
if err != nil {
t.Errorf("toNorm(%s) failed: %v (wd=%s)\n", arg, err, wd)
diff --git a/src/path/filepath/symlink_windows.go b/src/path/filepath/symlink_windows.go
index 9a436d5978..8047ff83c1 100644
--- a/src/path/filepath/symlink_windows.go
+++ b/src/path/filepath/symlink_windows.go
@@ -63,8 +63,6 @@ func toNorm(path string, normBase func(string) (string, error)) (string, error)
return path, nil
}
- path = Clean(path)
-
volume := normVolumeName(path)
path = path[len(volume):]