From 030ca34f5786f0b924dcab26379ee2f82104220d Mon Sep 17 00:00:00 2001 From: qmuntal Date: Thu, 1 Dec 2022 21:59:00 +0100 Subject: [PATCH] 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 Reviewed-by: Bryan Mills Reviewed-by: Damien Neil Run-TryBot: Quim Muntal --- src/path/filepath/path_windows_test.go | 10 ++++++++-- src/path/filepath/symlink_windows.go | 2 -- 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 e37dddceadb..8553485a2d0 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 9a436d59780..8047ff83c12 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):]