mirror of
https://github.com/rclone/rclone.git
synced 2025-12-31 07:33:33 +00:00
encoder: add option to encode . and .. names
This commit is contained in:
committed by
Nick Craig-Wood
parent
6c0a749a42
commit
d5cd026547
@@ -92,8 +92,22 @@ func (mask MultiEncoder) Encode(in string) string {
|
||||
encodeRightSpace = uint(mask)&EncodeRightSpace != 0
|
||||
encodeRightPeriod = uint(mask)&EncodeRightPeriod != 0
|
||||
encodeInvalidUnicode = uint(mask)&EncodeInvalidUtf8 != 0
|
||||
encodeDot = uint(mask)&EncodeDot != 0
|
||||
)
|
||||
|
||||
if encodeDot {
|
||||
switch in {
|
||||
case ".":
|
||||
return "."
|
||||
case "..":
|
||||
return ".."
|
||||
case ".":
|
||||
return string(QuoteRune) + "."
|
||||
case "..":
|
||||
return string(QuoteRune) + "." + string(QuoteRune) + "."
|
||||
}
|
||||
}
|
||||
|
||||
// handle prefix only replacements
|
||||
prefix := ""
|
||||
if encodeLeftSpace && len(in) > 0 { // Leading SPACE
|
||||
@@ -299,8 +313,22 @@ func (mask MultiEncoder) Decode(in string) string {
|
||||
encodeRightSpace = uint(mask)&EncodeRightSpace != 0
|
||||
encodeRightPeriod = uint(mask)&EncodeRightPeriod != 0
|
||||
encodeInvalidUnicode = uint(mask)&EncodeInvalidUtf8 != 0
|
||||
encodeDot = uint(mask)&EncodeDot != 0
|
||||
)
|
||||
|
||||
if encodeDot {
|
||||
switch in {
|
||||
case ".":
|
||||
return "."
|
||||
case "..":
|
||||
return ".."
|
||||
case string(QuoteRune) + ".":
|
||||
return "."
|
||||
case string(QuoteRune) + "." + string(QuoteRune) + ".":
|
||||
return ".."
|
||||
}
|
||||
}
|
||||
|
||||
// handle prefix only replacements
|
||||
prefix := ""
|
||||
if r, l1 := utf8.DecodeRuneInString(in); encodeLeftSpace && r == '␠' { // SYMBOL FOR SPACE
|
||||
|
||||
Reference in New Issue
Block a user