mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 08:58:26 +08:00
lib/encoder: add Exclamation mark encoding
This commit is contained in:
parent
27b281ef69
commit
bac9abebfb
|
@ -369,6 +369,7 @@ will show you the defaults for the backends.
|
|||
| Dollar | `$` | `$` |
|
||||
| Dot | `.` or `..` as entire string | `.`, `..` |
|
||||
| DoubleQuote | `"` | `"` |
|
||||
| Exclamation | `!` | `!` |
|
||||
| Hash | `#` | `#` |
|
||||
| InvalidUtf8 | An invalid UTF-8 character (e.g. latin1) | `<60>` |
|
||||
| LeftCrLfHtVt | CR 0x0D, LF 0x0A, HT 0x09, VT 0x0B on the left of a string | `␍`, `␊`, `␉`, `␋` |
|
||||
|
|
|
@ -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 '?':
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,6 +45,7 @@ var maskBits = []struct {
|
|||
{encoder.EncodeLtGt, "EncodeLtGt"},
|
||||
{encoder.EncodeSquareBracket, "EncodeSquareBracket"},
|
||||
{encoder.EncodeSemicolon, "EncodeSemicolon"},
|
||||
{encoder.EncodeExclamation, "EncodeExclamation"},
|
||||
{encoder.EncodeDollar, "EncodeDollar"},
|
||||
{encoder.EncodeDoubleQuote, "EncodeDoubleQuote"},
|
||||
{encoder.EncodeColon, "EncodeColon"},
|
||||
|
@ -118,6 +119,11 @@ var allMappings = []mapping{{
|
|||
}, []rune{
|
||||
';',
|
||||
}}, {
|
||||
encoder.EncodeExclamation, []rune{
|
||||
'!',
|
||||
}, []rune{
|
||||
'!',
|
||||
}}, {
|
||||
encoder.EncodeDoubleQuote, []rune{
|
||||
'"',
|
||||
}, []rune{
|
||||
|
|
Loading…
Reference in New Issue
Block a user