From: qmuntal Date: Thu, 1 Dec 2022 20:59:00 +0000 (+0100) Subject: path/filepath: remove extra Clean call in EvalSymlinks on Windows X-Git-Tag: go1.21rc1~1824 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=030ca34f5786f0b924dcab26379ee2f82104220d;p=gostls13.git 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 --- 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):]