mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
path/filepath: return cleaned path from Rel
As the doc says, Rel should return a cleaned path. Fixes #75763 Change-Id: Ic0f5a3b1da3cc4cf3c31fdb1a88ebcc4ea6f9169 Reviewed-on: https://go-review.googlesource.com/c/go/+/709675 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
parent
de9da0de30
commit
ee163197a8
2 changed files with 2 additions and 1 deletions
|
|
@ -248,7 +248,7 @@ func Rel(basepath, targpath string) (string, error) {
|
||||||
buf[n] = Separator
|
buf[n] = Separator
|
||||||
copy(buf[n+1:], targ[t0:])
|
copy(buf[n+1:], targ[t0:])
|
||||||
}
|
}
|
||||||
return string(buf), nil
|
return Clean(string(buf)), nil
|
||||||
}
|
}
|
||||||
return targ[t0:], nil
|
return targ[t0:], nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1506,6 +1506,7 @@ var reltests = []RelTests{
|
||||||
{"/../../a/b", "/../../a/b/c/d", "c/d"},
|
{"/../../a/b", "/../../a/b/c/d", "c/d"},
|
||||||
{".", "a/b", "a/b"},
|
{".", "a/b", "a/b"},
|
||||||
{".", "..", ".."},
|
{".", "..", ".."},
|
||||||
|
{"", "../../.", "../.."},
|
||||||
|
|
||||||
// can't do purely lexically
|
// can't do purely lexically
|
||||||
{"..", ".", "err"},
|
{"..", ".", "err"},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue