]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: remove extra Clean call in EvalSymlinks on Windows
authorqmuntal <quimmuntal@gmail.com>
Thu, 1 Dec 2022 20:59:00 +0000 (21:59 +0100)
committerQuim Muntal <quimmuntal@gmail.com>
Tue, 24 Jan 2023 07:42:17 +0000 (07:42 +0000)
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>

src/path/filepath/path_windows_test.go
src/path/filepath/symlink_windows.go

index e37dddceadbdf1510ee0df7eaf7dba9fc04358b0..8553485a2d0833bdac394e973f83005e5ef64023 100644 (file)
@@ -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)
index 9a436d59780d92ede3e732b50931bb339c1710c0..8047ff83c12ec3115868c0d76467ad3c58fb8918 100644 (file)
@@ -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):]