mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 02:52:26 -05:00
[bugfix] bump go-kv version with logfmt quote fix (#2108)
This commit is contained in:
parent
5e368d3089
commit
8ea7f551a0
8 changed files with 49 additions and 26 deletions
1
vendor/codeberg.org/gruf/go-kv/format/README.md
generated
vendored
1
vendor/codeberg.org/gruf/go-kv/format/README.md
generated
vendored
|
|
@ -2,4 +2,3 @@ String formatting package using Rust-style formatting directives, geared specifc
|
|||
|
||||
Generally more visually friendly than `"fmt"` and performance is much improved.
|
||||
|
||||

|
||||
2
vendor/codeberg.org/gruf/go-kv/format/format.go
generated
vendored
2
vendor/codeberg.org/gruf/go-kv/format/format.go
generated
vendored
|
|
@ -316,7 +316,9 @@ func (f format) AppendStringSafe(s string) {
|
|||
f.Buffer.B = strconv.AppendQuote(f.Buffer.B, s)
|
||||
} else if ContainsDoubleQuote(s) {
|
||||
// Contains double quotes, needs escaping
|
||||
f.Buffer.B = append(f.Buffer.B, '"')
|
||||
f.Buffer.B = AppendEscape(f.Buffer.B, s)
|
||||
f.Buffer.B = append(f.Buffer.B, '"')
|
||||
} else if len(s) == 0 || ContainsSpaceOrTab(s) {
|
||||
// Contains space / empty, needs quotes
|
||||
f.Buffer.B = append(f.Buffer.B, '"')
|
||||
|
|
|
|||
33
vendor/codeberg.org/gruf/go-kv/format/util.go
generated
vendored
33
vendor/codeberg.org/gruf/go-kv/format/util.go
generated
vendored
|
|
@ -29,7 +29,7 @@ func IsSafeASCII(str string) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// ContainsSpaceOrTab checks if "s" contains space or tabs.
|
||||
// ContainsSpaceOrTab checks if "s" contains space or tabs. EXPECTS ASCII.
|
||||
func ContainsSpaceOrTab(s string) bool {
|
||||
if i := strings.IndexByte(s, ' '); i >= 0 {
|
||||
return true // note using indexbyte as it is ASM.
|
||||
|
|
@ -39,31 +39,26 @@ func ContainsSpaceOrTab(s string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// ContainsDoubleQuote checks if "s" contains a double quote.
|
||||
// ContainsDoubleQuote checks if "s" contains a double quote. EXPECTS ASCII.
|
||||
func ContainsDoubleQuote(s string) bool {
|
||||
return (strings.IndexByte(s, '"') >= 0)
|
||||
}
|
||||
|
||||
// AppendEscape will append 's' to 'dst' and escape any double quotes.
|
||||
// AppendEscape will append 's' to 'dst' and escape any double quotes. EXPECTS ASCII.
|
||||
func AppendEscape(dst []byte, str string) []byte {
|
||||
var delim bool
|
||||
for i := range str {
|
||||
if str[i] == '\\' && !delim {
|
||||
// Set delim flag
|
||||
delim = true
|
||||
continue
|
||||
} else if str[i] == '"' && !delim {
|
||||
// Append escaped double quote
|
||||
dst = append(dst, `\"`...)
|
||||
continue
|
||||
} else if delim {
|
||||
// Append skipped slash
|
||||
dst = append(dst, `\`...)
|
||||
delim = false
|
||||
}
|
||||
switch str[i] {
|
||||
case '\\':
|
||||
// Append delimited '\'
|
||||
dst = append(dst, '\\', '\\')
|
||||
|
||||
// Append char as-is
|
||||
dst = append(dst, str[i])
|
||||
case '"':
|
||||
// Append delimited '"'
|
||||
dst = append(dst, '\\', '"')
|
||||
default:
|
||||
// Append char as-is
|
||||
dst = append(dst, str[i])
|
||||
}
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue