]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: in Rel use case-insensitive comparison on Windows
authorMohit Agarwal <mohit@sdf.org>
Mon, 16 Nov 2015 15:29:35 +0000 (20:59 +0530)
committerAlex Brainman <alex.brainman@gmail.com>
Tue, 17 Nov 2015 23:48:47 +0000 (23:48 +0000)
Compare basepath and targetpath using strings.EqualFold.  The absence
of this on Windows causes an unterminating condition in `for` statement
later in the function.

Fixes #13258

Change-Id: Ib5a0caba864ee425dc75ece47b9cf6fb626f47f1
Reviewed-on: https://go-review.googlesource.com/16857
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
src/path/filepath/path.go
src/path/filepath/path_test.go

index 7164c070bbd6d7ee022716b3b00eae14042e9dfa..dd6f3e7a994531116300bbaa8efdb36b6c7bfb06 100644 (file)
@@ -258,7 +258,7 @@ func Rel(basepath, targpath string) (string, error) {
        targVol := VolumeName(targpath)
        base := Clean(basepath)
        targ := Clean(targpath)
-       if targ == base {
+       if sameWord(targ, base) {
                return ".", nil
        }
        base = base[len(baseVol):]
index 057aa6a2c0015fc7e695dd1b46bbf5fc658b3d9c..e41a97da1135a7fca21f41ad3e035d8e4bcc0207 100644 (file)
@@ -1034,6 +1034,8 @@ var winreltests = []RelTests{
        {`C:\`, `D:\`, `err`},
        {`C:`, `D:`, `err`},
        {`C:\Projects`, `c:\projects\src`, `src`},
+       {`C:\Projects`, `c:\projects`, `.`},
+       {`C:\Projects\a\..`, `c:\projects`, `.`},
 }
 
 func TestRel(t *testing.T) {