aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath
diff options
context:
space:
mode:
authorMohit Agarwal <mohit@sdf.org>2015-11-16 20:59:35 +0530
committerAlex Brainman <alex.brainman@gmail.com>2015-11-17 23:48:47 +0000
commit2619dccf3c44a38c7514c3db29d871d0640e83cb (patch)
tree77b303bf052292ceef4d221af587b062177e4c68 /src/path/filepath
parent4d4a266780822acfdf58eaf9c0ba914024ff8bfa (diff)
downloadgo-2619dccf3c44a38c7514c3db29d871d0640e83cb.tar.xz
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>
Diffstat (limited to 'src/path/filepath')
-rw-r--r--src/path/filepath/path.go2
-rw-r--r--src/path/filepath/path_test.go2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
index 7164c070bb..dd6f3e7a99 100644
--- a/src/path/filepath/path.go
+++ b/src/path/filepath/path.go
@@ -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):]
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
index 057aa6a2c0..e41a97da11 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -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) {