diff options
| author | QtRoS <mrqtros@gmail.com> | 2018-09-25 00:01:39 +0300 |
|---|---|---|
| committer | Alex Brainman <alex.brainman@gmail.com> | 2018-09-29 04:26:02 +0000 |
| commit | d1f7470c217691dca4e339c77bf8c4175b8db168 (patch) | |
| tree | 0b548fe28b2b4914981297c9c278881b833bb563 /src/path/filepath/path.go | |
| parent | 1c95d9728aa5c8638db1bbabfb6ae764c4613c68 (diff) | |
| download | go-d1f7470c217691dca4e339c77bf8c4175b8db168.tar.xz | |
path/filepath: fix Windows-specific Clean bug
Fixes #27791
Change-Id: I762fa663379086c24cb4ddc8233a2c0a82b1238e
Reviewed-on: https://go-review.googlesource.com/137055
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/path.go')
| -rw-r--r-- | src/path/filepath/path.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go index aba1717e7d..bbb90306a7 100644 --- a/src/path/filepath/path.go +++ b/src/path/filepath/path.go @@ -96,14 +96,19 @@ func Clean(path string) string { } return originalPath + "." } + + n := len(path) + if volLen > 2 && n == 1 && os.IsPathSeparator(path[0]) { + // UNC volume name with trailing slash. + return FromSlash(originalPath[:volLen]) + } rooted := os.IsPathSeparator(path[0]) // Invariants: // reading from path; r is index of next byte to process. - // writing to buf; w is index of next byte to write. - // dotdot is index in buf where .. must stop, either because + // writing to out; w is index of next byte to write. + // dotdot is index in out where .. must stop, either because // it is the leading slash or it is a leading ../../.. prefix. - n := len(path) out := lazybuf{path: path, volAndPath: originalPath, volLen: volLen} r, dotdot := 0, 0 if rooted { |
