MM-34932: Bump dependencies (#17708)
https://mattermost.atlassian.net/browse/MM-34932 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fff09bf210
Коммит
3299a72adb
8
vendor/github.com/tidwall/gjson/README.md
сгенерированный
поставляемый
8
vendor/github.com/tidwall/gjson/README.md
сгенерированный
поставляемый
@@ -150,10 +150,6 @@ result.Less(token Result, caseSensitive bool) bool
|
||||
|
||||
The `result.Value()` function returns an `interface{}` which requires type assertion and is one of the following Go types:
|
||||
|
||||
The `result.Array()` function returns back an array of values.
|
||||
If the result represents a non-existent value, then an empty array will be returned.
|
||||
If the result is not a JSON array, the return value will be an array containing one result.
|
||||
|
||||
```go
|
||||
boolean >> bool
|
||||
number >> float64
|
||||
@@ -163,6 +159,10 @@ array >> []interface{}
|
||||
object >> map[string]interface{}
|
||||
```
|
||||
|
||||
The `result.Array()` function returns back an array of values.
|
||||
If the result represents a non-existent value, then an empty array will be returned.
|
||||
If the result is not a JSON array, the return value will be an array containing one result.
|
||||
|
||||
### 64-bit integers
|
||||
|
||||
The `result.Int()` and `result.Uint()` calls are capable of reading all 64 bits, allowing for large JSON integers.
|
||||
|
||||
17
vendor/github.com/tidwall/gjson/SYNTAX.md
сгенерированный
поставляемый
17
vendor/github.com/tidwall/gjson/SYNTAX.md
сгенерированный
поставляемый
@@ -77,14 +77,21 @@ Special purpose characters, such as `.`, `*`, and `?` can be escaped with `\`.
|
||||
fav\.movie "Deer Hunter"
|
||||
```
|
||||
|
||||
You'll also need to make sure that the `\` character is correctly escaped when hardcoding a path in source code.
|
||||
You'll also need to make sure that the `\` character is correctly escaped when hardcoding a path in you source code.
|
||||
|
||||
```go
|
||||
res := gjson.Get(json, "fav\\.movie") // must escape the slash
|
||||
res := gjson.Get(json, `fav\.movie`) // no need to escape the slash
|
||||
|
||||
// Go
|
||||
val := gjson.Get(json, "fav\\.movie") // must escape the slash
|
||||
val := gjson.Get(json, `fav\.movie`) // no need to escape the slash
|
||||
```
|
||||
|
||||
```rust
|
||||
// Rust
|
||||
let val = gjson::get(json, "fav\\.movie") // must escape the slash
|
||||
let val = gjson::get(json, r#"fav\.movie"#) // no need to escape the slash
|
||||
```
|
||||
|
||||
|
||||
### Arrays
|
||||
|
||||
The `#` character allows for digging into JSON Arrays.
|
||||
@@ -248,6 +255,8 @@ gjson.AddModifier("case", func(json, arg string) string {
|
||||
"children.@case:lower.@reverse" ["jack","alex","sara"]
|
||||
```
|
||||
|
||||
*Note: Custom modifiers are not yet available in the Rust version*
|
||||
|
||||
### Multipaths
|
||||
|
||||
Starting with v1.3.0, GJSON added the ability to join multiple paths together
|
||||
|
||||
198
vendor/github.com/tidwall/gjson/gjson.go
сгенерированный
поставляемый
198
vendor/github.com/tidwall/gjson/gjson.go
сгенерированный
поставляемый
@@ -714,10 +714,10 @@ type arrayPathResult struct {
|
||||
alogkey string
|
||||
query struct {
|
||||
on bool
|
||||
all bool
|
||||
path string
|
||||
op string
|
||||
value string
|
||||
all bool
|
||||
}
|
||||
}
|
||||
|
||||
@@ -750,120 +750,27 @@ func parseArrayPath(path string) (r arrayPathResult) {
|
||||
} else if path[1] == '[' || path[1] == '(' {
|
||||
// query
|
||||
r.query.on = true
|
||||
if true {
|
||||
qpath, op, value, _, fi, ok := parseQuery(path[i:])
|
||||
if !ok {
|
||||
// bad query, end now
|
||||
break
|
||||
}
|
||||
r.query.path = qpath
|
||||
r.query.op = op
|
||||
r.query.value = value
|
||||
i = fi - 1
|
||||
if i+1 < len(path) && path[i+1] == '#' {
|
||||
r.query.all = true
|
||||
}
|
||||
} else {
|
||||
var end byte
|
||||
if path[1] == '[' {
|
||||
end = ']'
|
||||
} else {
|
||||
end = ')'
|
||||
}
|
||||
i += 2
|
||||
// whitespace
|
||||
for ; i < len(path); i++ {
|
||||
if path[i] > ' ' {
|
||||
break
|
||||
}
|
||||
}
|
||||
s := i
|
||||
for ; i < len(path); i++ {
|
||||
if path[i] <= ' ' ||
|
||||
path[i] == '!' ||
|
||||
path[i] == '=' ||
|
||||
path[i] == '<' ||
|
||||
path[i] == '>' ||
|
||||
path[i] == '%' ||
|
||||
path[i] == end {
|
||||
break
|
||||
}
|
||||
}
|
||||
r.query.path = path[s:i]
|
||||
// whitespace
|
||||
for ; i < len(path); i++ {
|
||||
if path[i] > ' ' {
|
||||
break
|
||||
}
|
||||
}
|
||||
if i < len(path) {
|
||||
s = i
|
||||
if path[i] == '!' {
|
||||
if i < len(path)-1 && (path[i+1] == '=' ||
|
||||
path[i+1] == '%') {
|
||||
i++
|
||||
}
|
||||
} else if path[i] == '<' || path[i] == '>' {
|
||||
if i < len(path)-1 && path[i+1] == '=' {
|
||||
i++
|
||||
}
|
||||
} else if path[i] == '=' {
|
||||
if i < len(path)-1 && path[i+1] == '=' {
|
||||
s++
|
||||
i++
|
||||
}
|
||||
}
|
||||
i++
|
||||
r.query.op = path[s:i]
|
||||
// whitespace
|
||||
for ; i < len(path); i++ {
|
||||
if path[i] > ' ' {
|
||||
break
|
||||
}
|
||||
}
|
||||
s = i
|
||||
for ; i < len(path); i++ {
|
||||
if path[i] == '"' {
|
||||
i++
|
||||
s2 := i
|
||||
for ; i < len(path); i++ {
|
||||
if path[i] > '\\' {
|
||||
continue
|
||||
}
|
||||
if path[i] == '"' {
|
||||
// look for an escaped slash
|
||||
if path[i-1] == '\\' {
|
||||
n := 0
|
||||
for j := i - 2; j > s2-1; j-- {
|
||||
if path[j] != '\\' {
|
||||
break
|
||||
}
|
||||
n++
|
||||
}
|
||||
if n%2 == 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if path[i] == end {
|
||||
if i+1 < len(path) && path[i+1] == '#' {
|
||||
r.query.all = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if i > len(path) {
|
||||
i = len(path)
|
||||
}
|
||||
v := path[s:i]
|
||||
for len(v) > 0 && v[len(v)-1] <= ' ' {
|
||||
v = v[:len(v)-1]
|
||||
}
|
||||
r.query.value = v
|
||||
qpath, op, value, _, fi, vesc, ok :=
|
||||
parseQuery(path[i:])
|
||||
if !ok {
|
||||
// bad query, end now
|
||||
break
|
||||
}
|
||||
if len(value) > 2 && value[0] == '"' &&
|
||||
value[len(value)-1] == '"' {
|
||||
value = value[1 : len(value)-1]
|
||||
if vesc {
|
||||
value = unescape(value)
|
||||
}
|
||||
}
|
||||
r.query.path = qpath
|
||||
r.query.op = op
|
||||
r.query.value = value
|
||||
|
||||
i = fi - 1
|
||||
if i+1 < len(path) && path[i+1] == '#' {
|
||||
r.query.all = true
|
||||
}
|
||||
}
|
||||
}
|
||||
continue
|
||||
@@ -889,11 +796,11 @@ func parseArrayPath(path string) (r arrayPathResult) {
|
||||
// # middle
|
||||
// .cap # right
|
||||
func parseQuery(query string) (
|
||||
path, op, value, remain string, i int, ok bool,
|
||||
path, op, value, remain string, i int, vesc, ok bool,
|
||||
) {
|
||||
if len(query) < 2 || query[0] != '#' ||
|
||||
(query[1] != '(' && query[1] != '[') {
|
||||
return "", "", "", "", i, false
|
||||
return "", "", "", "", i, false, false
|
||||
}
|
||||
i = 2
|
||||
j := 0 // start of value part
|
||||
@@ -921,6 +828,7 @@ func parseQuery(query string) (
|
||||
i++
|
||||
for ; i < len(query); i++ {
|
||||
if query[i] == '\\' {
|
||||
vesc = true
|
||||
i++
|
||||
} else if query[i] == '"' {
|
||||
break
|
||||
@@ -929,7 +837,7 @@ func parseQuery(query string) (
|
||||
}
|
||||
}
|
||||
if depth > 0 {
|
||||
return "", "", "", "", i, false
|
||||
return "", "", "", "", i, false, false
|
||||
}
|
||||
if j > 0 {
|
||||
path = trim(query[2:j])
|
||||
@@ -966,7 +874,7 @@ func parseQuery(query string) (
|
||||
path = trim(query[2:i])
|
||||
remain = query[i+1:]
|
||||
}
|
||||
return path, op, value, remain, i + 1, true
|
||||
return path, op, value, remain, i + 1, vesc, true
|
||||
}
|
||||
|
||||
func trim(s string) string {
|
||||
@@ -1266,8 +1174,14 @@ func parseObject(c *parseContext, i int, path string) (int, bool) {
|
||||
}
|
||||
func queryMatches(rp *arrayPathResult, value Result) bool {
|
||||
rpv := rp.query.value
|
||||
if len(rpv) > 2 && rpv[0] == '"' && rpv[len(rpv)-1] == '"' {
|
||||
rpv = rpv[1 : len(rpv)-1]
|
||||
if len(rpv) > 0 && rpv[0] == '~' {
|
||||
// convert to bool
|
||||
rpv = rpv[1:]
|
||||
if value.Bool() {
|
||||
value = Result{Type: True}
|
||||
} else {
|
||||
value = Result{Type: False}
|
||||
}
|
||||
}
|
||||
if !value.Exists() {
|
||||
return false
|
||||
@@ -1406,7 +1320,6 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
for i < len(c.json)+1 {
|
||||
if !rp.arrch {
|
||||
pmatch = partidx == h
|
||||
@@ -1608,10 +1521,17 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
|
||||
c.calcd = true
|
||||
return i + 1, true
|
||||
}
|
||||
if len(multires) > 0 && !c.value.Exists() {
|
||||
c.value = Result{
|
||||
Raw: string(append(multires, ']')),
|
||||
Type: JSON,
|
||||
if !c.value.Exists() {
|
||||
if len(multires) > 0 {
|
||||
c.value = Result{
|
||||
Raw: string(append(multires, ']')),
|
||||
Type: JSON,
|
||||
}
|
||||
} else if rp.query.all {
|
||||
c.value = Result{
|
||||
Raw: "[]",
|
||||
Type: JSON,
|
||||
}
|
||||
}
|
||||
}
|
||||
return i + 1, false
|
||||
@@ -2176,11 +2096,6 @@ func parseAny(json string, i int, hit bool) (int, Result, bool) {
|
||||
return i, res, false
|
||||
}
|
||||
|
||||
var ( // used for testing
|
||||
testWatchForFallback bool
|
||||
testLastWasFallback bool
|
||||
)
|
||||
|
||||
// GetMany searches json for the multiple paths.
|
||||
// The return value is a Result array where the number of items
|
||||
// will be equal to the number of input paths.
|
||||
@@ -2381,6 +2296,12 @@ func validnumber(data []byte, i int) (outi int, ok bool) {
|
||||
// sign
|
||||
if data[i] == '-' {
|
||||
i++
|
||||
if i == len(data) {
|
||||
return i, false
|
||||
}
|
||||
if data[i] < '0' || data[i] > '9' {
|
||||
return i, false
|
||||
}
|
||||
}
|
||||
// int
|
||||
if i == len(data) {
|
||||
@@ -2745,19 +2666,24 @@ func modFlatten(json, arg string) string {
|
||||
out = append(out, '[')
|
||||
var idx int
|
||||
res.ForEach(func(_, value Result) bool {
|
||||
if idx > 0 {
|
||||
out = append(out, ',')
|
||||
}
|
||||
var raw string
|
||||
if value.IsArray() {
|
||||
if deep {
|
||||
out = append(out, unwrap(modFlatten(value.Raw, arg))...)
|
||||
raw = unwrap(modFlatten(value.Raw, arg))
|
||||
} else {
|
||||
out = append(out, unwrap(value.Raw)...)
|
||||
raw = unwrap(value.Raw)
|
||||
}
|
||||
} else {
|
||||
out = append(out, value.Raw...)
|
||||
raw = value.Raw
|
||||
}
|
||||
raw = strings.TrimSpace(raw)
|
||||
if len(raw) > 0 {
|
||||
if idx > 0 {
|
||||
out = append(out, ',')
|
||||
}
|
||||
out = append(out, raw...)
|
||||
idx++
|
||||
}
|
||||
idx++
|
||||
return true
|
||||
})
|
||||
out = append(out, ']')
|
||||
|
||||
53
vendor/github.com/tidwall/pretty/README.md
сгенерированный
поставляемый
53
vendor/github.com/tidwall/pretty/README.md
сгенерированный
поставляемый
@@ -79,46 +79,6 @@ Will format the json to:
|
||||
{"name":{"first":"Tom","last":"Anderson"},"age":37,"children":["Sara","Alex","Jack"],"fav.movie":"Deer Hunter","friends":[{"first":"Janet","last":"Murphy","age":44}]}```
|
||||
```
|
||||
|
||||
## Spec
|
||||
|
||||
Spec cleans comments and trailing commas from input JSON, converting it to
|
||||
valid JSON per the official spec: https://tools.ietf.org/html/rfc8259
|
||||
|
||||
The resulting JSON will always be the same length as the input and it will
|
||||
include all of the same line breaks at matching offsets. This is to ensure
|
||||
the result can be later processed by a external parser and that that
|
||||
parser will report messages or errors with the correct offsets.
|
||||
|
||||
The following example uses a JSON document that has comments and trailing
|
||||
commas and converts it prior to unmarshalling to using the standard Go
|
||||
JSON library.
|
||||
|
||||
```go
|
||||
|
||||
data := `
|
||||
{
|
||||
/* Dev Machine */
|
||||
"dbInfo": {
|
||||
"host": "localhost",
|
||||
"port": 5432, // use full email address
|
||||
"username": "josh",
|
||||
"password": "pass123", // use a hashed password
|
||||
}
|
||||
/* Only SMTP Allowed */
|
||||
"emailInfo": {
|
||||
"email": "josh@example.com",
|
||||
"password": "pass123",
|
||||
"smtp": "smpt.example.com",
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
err := json.Unmarshal(pretty.Spec(data), &config)
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Customized output
|
||||
|
||||
There's a `PrettyOptions(json, opts)` function which allows for customizing the output with the following options:
|
||||
@@ -143,14 +103,15 @@ type Options struct {
|
||||
|
||||
Benchmarks of Pretty alongside the builtin `encoding/json` Indent/Compact methods.
|
||||
```
|
||||
BenchmarkPretty-8 1000000 1283 ns/op 720 B/op 2 allocs/op
|
||||
BenchmarkUgly-8 3000000 426 ns/op 240 B/op 1 allocs/op
|
||||
BenchmarkUglyInPlace-8 5000000 340 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkJSONIndent-8 300000 4628 ns/op 1069 B/op 4 allocs/op
|
||||
BenchmarkJSONCompact-8 1000000 2469 ns/op 758 B/op 4 allocs/op
|
||||
BenchmarkPretty-16 1000000 1034 ns/op 720 B/op 2 allocs/op
|
||||
BenchmarkPrettySortKeys-16 586797 1983 ns/op 2848 B/op 14 allocs/op
|
||||
BenchmarkUgly-16 4652365 254 ns/op 240 B/op 1 allocs/op
|
||||
BenchmarkUglyInPlace-16 6481233 183 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkJSONIndent-16 450654 2687 ns/op 1221 B/op 0 allocs/op
|
||||
BenchmarkJSONCompact-16 685111 1699 ns/op 442 B/op 0 allocs/op
|
||||
```
|
||||
|
||||
*These benchmarks were run on a MacBook Pro 15" 2.8 GHz Intel Core i7 using Go 1.7.*
|
||||
*These benchmarks were run on a MacBook Pro 2.4 GHz 8-Core Intel Core i9.*
|
||||
|
||||
## Contact
|
||||
Josh Baker [@tidwall](http://twitter.com/tidwall)
|
||||
|
||||
3
vendor/github.com/tidwall/pretty/go.mod
сгенерированный
поставляемый
Обычный файл
3
vendor/github.com/tidwall/pretty/go.mod
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,3 @@
|
||||
module github.com/tidwall/pretty
|
||||
|
||||
go 1.16
|
||||
105
vendor/github.com/tidwall/pretty/pretty.go
сгенерированный
поставляемый
105
vendor/github.com/tidwall/pretty/pretty.go
сгенерированный
поставляемый
@@ -1,7 +1,10 @@
|
||||
package pretty
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"sort"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Options is Pretty options
|
||||
@@ -121,6 +124,7 @@ type pair struct {
|
||||
type byKeyVal struct {
|
||||
sorted bool
|
||||
json []byte
|
||||
buf []byte
|
||||
pairs []pair
|
||||
}
|
||||
|
||||
@@ -128,21 +132,110 @@ func (arr *byKeyVal) Len() int {
|
||||
return len(arr.pairs)
|
||||
}
|
||||
func (arr *byKeyVal) Less(i, j int) bool {
|
||||
key1 := arr.json[arr.pairs[i].kstart+1 : arr.pairs[i].kend-1]
|
||||
key2 := arr.json[arr.pairs[j].kstart+1 : arr.pairs[j].kend-1]
|
||||
if string(key1) < string(key2) {
|
||||
if arr.isLess(i, j, byKey) {
|
||||
return true
|
||||
}
|
||||
if string(key1) > string(key2) {
|
||||
if arr.isLess(j, i, byKey) {
|
||||
return false
|
||||
}
|
||||
return arr.pairs[i].vstart < arr.pairs[j].vstart
|
||||
return arr.isLess(i, j, byVal)
|
||||
}
|
||||
func (arr *byKeyVal) Swap(i, j int) {
|
||||
arr.pairs[i], arr.pairs[j] = arr.pairs[j], arr.pairs[i]
|
||||
arr.sorted = true
|
||||
}
|
||||
|
||||
type byKind int
|
||||
|
||||
const (
|
||||
byKey byKind = 0
|
||||
byVal byKind = 1
|
||||
)
|
||||
|
||||
type jtype int
|
||||
|
||||
const (
|
||||
jnull jtype = iota
|
||||
jfalse
|
||||
jnumber
|
||||
jstring
|
||||
jtrue
|
||||
jjson
|
||||
)
|
||||
|
||||
func getjtype(v []byte) jtype {
|
||||
if len(v) == 0 {
|
||||
return jnull
|
||||
}
|
||||
switch v[0] {
|
||||
case '"':
|
||||
return jstring
|
||||
case 'f':
|
||||
return jfalse
|
||||
case 't':
|
||||
return jtrue
|
||||
case 'n':
|
||||
return jnull
|
||||
case '[', '{':
|
||||
return jjson
|
||||
default:
|
||||
return jnumber
|
||||
}
|
||||
}
|
||||
|
||||
func (arr *byKeyVal) isLess(i, j int, kind byKind) bool {
|
||||
k1 := arr.json[arr.pairs[i].kstart:arr.pairs[i].kend]
|
||||
k2 := arr.json[arr.pairs[j].kstart:arr.pairs[j].kend]
|
||||
var v1, v2 []byte
|
||||
if kind == byKey {
|
||||
v1 = k1
|
||||
v2 = k2
|
||||
} else {
|
||||
v1 = bytes.TrimSpace(arr.buf[arr.pairs[i].vstart:arr.pairs[i].vend])
|
||||
v2 = bytes.TrimSpace(arr.buf[arr.pairs[j].vstart:arr.pairs[j].vend])
|
||||
if len(v1) >= len(k1)+1 {
|
||||
v1 = bytes.TrimSpace(v1[len(k1)+1:])
|
||||
}
|
||||
if len(v2) >= len(k2)+1 {
|
||||
v2 = bytes.TrimSpace(v2[len(k2)+1:])
|
||||
}
|
||||
}
|
||||
t1 := getjtype(v1)
|
||||
t2 := getjtype(v2)
|
||||
if t1 < t2 {
|
||||
return true
|
||||
}
|
||||
if t1 > t2 {
|
||||
return false
|
||||
}
|
||||
if t1 == jstring {
|
||||
s1 := parsestr(v1)
|
||||
s2 := parsestr(v2)
|
||||
return string(s1) < string(s2)
|
||||
}
|
||||
if t1 == jnumber {
|
||||
n1, _ := strconv.ParseFloat(string(v1), 64)
|
||||
n2, _ := strconv.ParseFloat(string(v2), 64)
|
||||
return n1 < n2
|
||||
}
|
||||
return string(v1) < string(v2)
|
||||
|
||||
}
|
||||
|
||||
func parsestr(s []byte) []byte {
|
||||
for i := 1; i < len(s); i++ {
|
||||
if s[i] == '\\' {
|
||||
var str string
|
||||
json.Unmarshal(s, &str)
|
||||
return []byte(str)
|
||||
}
|
||||
if s[i] == '"' {
|
||||
return s[1:i]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func appendPrettyObject(buf, json []byte, i int, open, close byte, pretty bool, width int, prefix, indent string, sortkeys bool, tabs, nl, max int) ([]byte, int, int, bool) {
|
||||
var ok bool
|
||||
if width > 0 {
|
||||
@@ -249,7 +342,7 @@ func sortPairs(json, buf []byte, pairs []pair) []byte {
|
||||
}
|
||||
vstart := pairs[0].vstart
|
||||
vend := pairs[len(pairs)-1].vend
|
||||
arr := byKeyVal{false, json, pairs}
|
||||
arr := byKeyVal{false, json, buf, pairs}
|
||||
sort.Stable(&arr)
|
||||
if !arr.sorted {
|
||||
return buf
|
||||
|
||||
Ссылка в новой задаче
Block a user