Commit 2619dccf authored by Mohit Agarwal's avatar Mohit Agarwal Committed by Alex Brainman

path/filepath: in Rel use case-insensitive comparison on Windows

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: default avatarAlex Brainman <alex.brainman@gmail.com>
parent 4d4a2667
...@@ -258,7 +258,7 @@ func Rel(basepath, targpath string) (string, error) { ...@@ -258,7 +258,7 @@ func Rel(basepath, targpath string) (string, error) {
targVol := VolumeName(targpath) targVol := VolumeName(targpath)
base := Clean(basepath) base := Clean(basepath)
targ := Clean(targpath) targ := Clean(targpath)
if targ == base { if sameWord(targ, base) {
return ".", nil return ".", nil
} }
base = base[len(baseVol):] base = base[len(baseVol):]
......
...@@ -1034,6 +1034,8 @@ var winreltests = []RelTests{ ...@@ -1034,6 +1034,8 @@ var winreltests = []RelTests{
{`C:\`, `D:\`, `err`}, {`C:\`, `D:\`, `err`},
{`C:`, `D:`, `err`}, {`C:`, `D:`, `err`},
{`C:\Projects`, `c:\projects\src`, `src`}, {`C:\Projects`, `c:\projects\src`, `src`},
{`C:\Projects`, `c:\projects`, `.`},
{`C:\Projects\a\..`, `c:\projects`, `.`},
} }
func TestRel(t *testing.T) { func TestRel(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment