mirror of
https://github.com/rclone/rclone.git
synced 2025-08-13 07:27:19 +02:00
lib/encoder: add Exclamation mark encoding
This commit is contained in:
@ -64,6 +64,7 @@ const (
|
||||
EncodeDot // . and .. names
|
||||
EncodeSquareBracket // []
|
||||
EncodeSemicolon // ;
|
||||
EncodeExclamation // !
|
||||
|
||||
// Synthetic
|
||||
EncodeWin = EncodeColon | EncodeQuestion | EncodeDoubleQuote | EncodeAsterisk | EncodeLtGt | EncodePipe // :?"*<>|
|
||||
@ -124,6 +125,7 @@ func init() {
|
||||
alias("LtGt", EncodeLtGt)
|
||||
alias("SquareBracket", EncodeSquareBracket)
|
||||
alias("Semicolon", EncodeSemicolon)
|
||||
alias("Exclamation", EncodeExclamation)
|
||||
alias("DoubleQuote", EncodeDoubleQuote)
|
||||
alias("SingleQuote", EncodeSingleQuote)
|
||||
alias("BackQuote", EncodeBackQuote)
|
||||
@ -336,6 +338,12 @@ func (mask MultiEncoder) Encode(in string) string {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if mask.Has(EncodeExclamation) { // !
|
||||
switch r {
|
||||
case '!', '!':
|
||||
return true
|
||||
}
|
||||
}
|
||||
if mask.Has(EncodeQuestion) { // ?
|
||||
switch r {
|
||||
case '?',
|
||||
@ -516,6 +524,17 @@ func (mask MultiEncoder) Encode(in string) string {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if mask.Has(EncodeExclamation) { // !
|
||||
switch r {
|
||||
case '!':
|
||||
out.WriteRune(r + fullOffset)
|
||||
continue
|
||||
case '!':
|
||||
out.WriteRune(QuoteRune)
|
||||
out.WriteRune(r)
|
||||
continue
|
||||
}
|
||||
}
|
||||
if mask.Has(EncodeQuestion) { // ?
|
||||
switch r {
|
||||
case '?':
|
||||
@ -772,7 +791,12 @@ func (mask MultiEncoder) Decode(in string) string {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if mask.Has(EncodeExclamation) { // !
|
||||
switch r {
|
||||
case '!':
|
||||
return true
|
||||
}
|
||||
}
|
||||
if mask.Has(EncodeQuestion) { // ?
|
||||
switch r {
|
||||
case '?':
|
||||
@ -939,6 +963,17 @@ func (mask MultiEncoder) Decode(in string) string {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if mask.Has(EncodeExclamation) { // !
|
||||
switch r {
|
||||
case '!':
|
||||
if unquote {
|
||||
out.WriteRune(r)
|
||||
} else {
|
||||
out.WriteRune(r - fullOffset)
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
if mask.Has(EncodeQuestion) { // ?
|
||||
switch r {
|
||||
case '?':
|
||||
|
Reference in New Issue
Block a user