1
0
mirror of https://github.com/golang/go synced 2024-11-17 23:04:56 -07:00

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: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
Mohit Agarwal 2015-11-16 20:59:35 +05:30 committed by Alex Brainman
parent 4d4a266780
commit 2619dccf3c
2 changed files with 3 additions and 1 deletions

View 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):]

View 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) {