summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-03-13 07:52:13 +0000
committerLibravatar GitHub <noreply@github.com>2023-03-13 07:52:13 +0000
commit0a864623f3d1084b6e8cc86f4b69e0adfa1c40cc (patch)
tree743196f1e7a788a8da897161868e7cf78def997f /vendor
parentupdate license headers (#1612) (diff)
downloadgotosocial-0a864623f3d1084b6e8cc86f4b69e0adfa1c40cc.tar.xz
[chore]: Bump codeberg.org/gruf/go-kv from 1.6.0 to 1.6.1 (#1619)
Bumps codeberg.org/gruf/go-kv from 1.6.0 to 1.6.1. --- updated-dependencies: - dependency-name: codeberg.org/gruf/go-kv dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor')
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field.go2
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field_fmt.go4
-rw-r--r--vendor/codeberg.org/gruf/go-kv/field_format.go2
-rw-r--r--vendor/codeberg.org/gruf/go-kv/util.go51
-rw-r--r--vendor/modules.txt2
5 files changed, 53 insertions, 8 deletions
diff --git a/vendor/codeberg.org/gruf/go-kv/field.go b/vendor/codeberg.org/gruf/go-kv/field.go
index 79c43822a..06c2b2573 100644
--- a/vendor/codeberg.org/gruf/go-kv/field.go
+++ b/vendor/codeberg.org/gruf/go-kv/field.go
@@ -75,7 +75,7 @@ type Field struct {
// Key returns the formatted key string of this Field.
func (f Field) Key() string {
buf := byteutil.Buffer{B: make([]byte, 0, bufsize/2)}
- AppendQuote(&buf, f.K)
+ AppendQuoteString(&buf, f.K)
return buf.String()
}
diff --git a/vendor/codeberg.org/gruf/go-kv/field_fmt.go b/vendor/codeberg.org/gruf/go-kv/field_fmt.go
index 33cec482b..5d6e77f4b 100644
--- a/vendor/codeberg.org/gruf/go-kv/field_fmt.go
+++ b/vendor/codeberg.org/gruf/go-kv/field_fmt.go
@@ -25,7 +25,7 @@ func (f Field) AppendFormat(buf *byteutil.Buffer, vbose bool) {
} else /* regular */ {
fmtstr = `%+v`
}
- AppendQuote(buf, f.K)
+ AppendQuoteString(buf, f.K)
buf.WriteByte('=')
appendValuef(buf, fmtstr, f.V)
}
@@ -50,7 +50,7 @@ func appendValuef(buf *byteutil.Buffer, format string, args ...interface{}) {
fmtbuf.B = fmt.Appendf(fmtbuf.B, format, args...)
// Append quoted value to dst buffer
- AppendQuote(buf, fmtbuf.String())
+ AppendQuoteValue(buf, fmtbuf.String())
// Drop overly large capacity buffers
if fmtbuf.Cap() > int(^uint16(0)) {
diff --git a/vendor/codeberg.org/gruf/go-kv/field_format.go b/vendor/codeberg.org/gruf/go-kv/field_format.go
index 18f35a6b9..f27c28ebd 100644
--- a/vendor/codeberg.org/gruf/go-kv/field_format.go
+++ b/vendor/codeberg.org/gruf/go-kv/field_format.go
@@ -16,7 +16,7 @@ func (f Field) AppendFormat(buf *byteutil.Buffer, vbose bool) {
} else /* regular */ {
fmtstr = "{:v}"
}
- AppendQuote(buf, f.K)
+ AppendQuoteString(buf, f.K)
buf.WriteByte('=')
format.Appendf(buf, fmtstr, f.V)
}
diff --git a/vendor/codeberg.org/gruf/go-kv/util.go b/vendor/codeberg.org/gruf/go-kv/util.go
index dfd91ad9d..ebcd3e304 100644
--- a/vendor/codeberg.org/gruf/go-kv/util.go
+++ b/vendor/codeberg.org/gruf/go-kv/util.go
@@ -8,8 +8,8 @@ import (
"codeberg.org/gruf/go-kv/format"
)
-// AppendQuote will append (and escape/quote where necessary) a formatted field string.
-func AppendQuote(buf *byteutil.Buffer, str string) {
+// AppendQuoteString will append (and escape/quote where necessary) a field string.
+func AppendQuoteString(buf *byteutil.Buffer, str string) {
switch {
case len(str) == 0:
// Append empty quotes.
@@ -27,7 +27,52 @@ func AppendQuote(buf *byteutil.Buffer, str string) {
return
case !isQuoted(str):
- // Single/double quoted already.
+ // Not single/double quoted already.
+
+ if format.ContainsSpaceOrTab(str) {
+ // Quote un-enclosed spaces.
+ buf.B = append(buf.B, '"')
+ buf.B = append(buf.B, str...)
+ buf.B = append(buf.B, '"')
+ return
+ }
+
+ if format.ContainsDoubleQuote(str) {
+ // Contains double quote, double quote
+ // and append escaped existing.
+ buf.B = append(buf.B, '"')
+ buf.B = format.AppendEscape(buf.B, str)
+ buf.B = append(buf.B, '"')
+ return
+ }
+ }
+
+ // Double quoted, enclosed in braces, or
+ // literally anything else: append as-is.
+ buf.B = append(buf.B, str...)
+ return
+}
+
+// AppendQuoteValue will append (and escape/quote where necessary) a formatted value string.
+func AppendQuoteValue(buf *byteutil.Buffer, str string) {
+ switch {
+ case len(str) == 0:
+ // Append empty quotes.
+ buf.B = append(buf.B, `""`...)
+ return
+
+ case len(str) == 1:
+ // Append quote single byte.
+ appendQuoteByte(buf, str[0])
+ return
+
+ case len(str) > format.SingleTermLine || !format.IsSafeASCII(str):
+ // Long line or contains non-ascii chars.
+ buf.B = strconv.AppendQuote(buf.B, str)
+ return
+
+ case !isQuoted(str):
+ // Not single/double quoted already.
// Get space / tab indices (if any).
s := strings.IndexByte(str, ' ')
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 63047cbbc..7aa4b6a46 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -39,7 +39,7 @@ codeberg.org/gruf/go-hashenc
# codeberg.org/gruf/go-iotools v0.0.0-20221224124424-3386841cb225
## explicit; go 1.19
codeberg.org/gruf/go-iotools
-# codeberg.org/gruf/go-kv v1.6.0
+# codeberg.org/gruf/go-kv v1.6.1
## explicit; go 1.19
codeberg.org/gruf/go-kv
codeberg.org/gruf/go-kv/format