summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-kv/util.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-08-21 06:54:30 +0000
committerLibravatar GitHub <noreply@github.com>2023-08-21 06:54:30 +0000
commit70d87f0ff0cc3fc6b38e1f111932c7523e9b8223 (patch)
treee023a32513acb93679f0db6dbe19f22930db305e /vendor/codeberg.org/gruf/go-kv/util.go
parent[chore]: Bump github.com/minio/minio-go/v7 from 7.0.61 to 7.0.62 (#2141) (diff)
downloadgotosocial-70d87f0ff0cc3fc6b38e1f111932c7523e9b8223.tar.xz
[chore]: Bump codeberg.org/gruf/go-kv from 1.6.3 to 1.6.4 (#2142)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-kv/util.go')
-rw-r--r--vendor/codeberg.org/gruf/go-kv/util.go37
1 files changed, 6 insertions, 31 deletions
diff --git a/vendor/codeberg.org/gruf/go-kv/util.go b/vendor/codeberg.org/gruf/go-kv/util.go
index ebcd3e304..c0c8ccdab 100644
--- a/vendor/codeberg.org/gruf/go-kv/util.go
+++ b/vendor/codeberg.org/gruf/go-kv/util.go
@@ -18,7 +18,9 @@ func AppendQuoteString(buf *byteutil.Buffer, str string) {
case len(str) == 1:
// Append quote single byte.
- appendQuoteByte(buf, str[0])
+ buf.B = append(buf.B, '\'')
+ buf.B = append(buf.B, format.Byte2Str(str[0])...)
+ buf.B = append(buf.B, '\'')
return
case len(str) > format.SingleTermLine || !format.IsSafeASCII(str):
@@ -63,7 +65,9 @@ func AppendQuoteValue(buf *byteutil.Buffer, str string) {
case len(str) == 1:
// Append quote single byte.
- appendQuoteByte(buf, str[0])
+ buf.B = append(buf.B, '\'')
+ buf.B = append(buf.B, format.Byte2Str(str[0])...)
+ buf.B = append(buf.B, '\'')
return
case len(str) > format.SingleTermLine || !format.IsSafeASCII(str):
@@ -115,35 +119,6 @@ func AppendQuoteValue(buf *byteutil.Buffer, str string) {
return
}
-// appendEscapeByte will append byte to buffer, quoting and escaping where necessary.
-func appendQuoteByte(buf *byteutil.Buffer, c byte) {
- switch c {
- // Double quote space.
- case ' ':
- buf.B = append(buf.B, '"', c, '"')
-
- // Escape + double quote.
- case '\a':
- buf.B = append(buf.B, '"', '\\', 'a', '"')
- case '\b':
- buf.B = append(buf.B, '"', '\\', 'b', '"')
- case '\f':
- buf.B = append(buf.B, '"', '\\', 'f', '"')
- case '\n':
- buf.B = append(buf.B, '"', '\\', 'n', '"')
- case '\r':
- buf.B = append(buf.B, '"', '\\', 'r', '"')
- case '\t':
- buf.B = append(buf.B, '"', '\\', 't', '"')
- case '\v':
- buf.B = append(buf.B, '"', '\\', 'v', '"')
-
- // Append as-is.
- default:
- buf.B = append(buf.B, c)
- }
-}
-
// isQuoted checks if string is single or double quoted.
func isQuoted(str string) bool {
return (str[0] == '"' && str[len(str)-1] == '"') ||