We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 34a6028 commit 4579775Copy full SHA for 4579775
src/archive/tar/strconv.go
@@ -73,13 +73,8 @@ func (f *formatter) formatString(b []byte, s string) {
73
// in the V7 path field as a directory even though the full path
74
// recorded elsewhere (e.g., via PAX record) contains no trailing slash.
75
if len(s) > len(b) && b[len(b)-1] == '/' {
76
- i := len(b) - 2 // s[len(b)-1] == '/'
77
- for ; i >= 0; i-- {
78
- if s[i] != '/' {
79
- break
80
- }
81
82
- b[i+1] = 0 // Replace trailing slash with NUL terminator
+ n := len(strings.TrimRight(s[:len(b)-1], "/"))
+ b[n] = 0 // Replace trailing slash with NUL terminator
83
}
84
85
0 commit comments