Skip to content

Commit c55fb33

Browse files
[release-branch.go1.12] path/filepath: revert "fix Windows-specific Clean bug"
Revert CL 137055, which changed Clean("\\somepath\dir\") to return "\\somepath\dir" on Windows. It's not entirely clear this is correct, as this path is really "\\server\share\", and as such the trailing slash may be the path on that share, much like "C:\". In any case, the change broke existing code, so roll it back for now and rethink for 1.13. Updates #27791 Updates #30307 Change-Id: I69200b1efe38bdb6d452b744582a2bfbb3acbcec Reviewed-on: https://go-review.googlesource.com/c/163077 Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]> (cherry picked from commit 153c0da) Reviewed-on: https://go-review.googlesource.com/c/163078 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 4754cba commit c55fb33

2 files changed

Lines changed: 3 additions & 11 deletions

File tree

src/path/filepath/path.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,14 @@ func Clean(path string) string {
9696
}
9797
return originalPath + "."
9898
}
99-
100-
n := len(path)
101-
if volLen > 2 && n == 1 && os.IsPathSeparator(path[0]) {
102-
// UNC volume name with trailing slash.
103-
return FromSlash(originalPath[:volLen])
104-
}
10599
rooted := os.IsPathSeparator(path[0])
106100

107101
// Invariants:
108102
// reading from path; r is index of next byte to process.
109-
// writing to out; w is index of next byte to write.
110-
// dotdot is index in out where .. must stop, either because
103+
// writing to buf; w is index of next byte to write.
104+
// dotdot is index in buf where .. must stop, either because
111105
// it is the leading slash or it is a leading ../../.. prefix.
106+
n := len(path)
112107
out := lazybuf{path: path, volAndPath: originalPath, volLen: volLen}
113108
r, dotdot := 0, 0
114109
if rooted {

src/path/filepath/path_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ var wincleantests = []PathTest{
9393
{`//host/share/foo/../baz`, `\\host\share\baz`},
9494
{`\\a\b\..\c`, `\\a\b\c`},
9595
{`\\a\b`, `\\a\b`},
96-
{`\\a\b\`, `\\a\b`},
97-
{`\\folder\share\foo`, `\\folder\share\foo`},
98-
{`\\folder\share\foo\`, `\\folder\share\foo`},
9996
}
10097

10198
func TestClean(t *testing.T) {

0 commit comments

Comments
 (0)