aboutsummaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/protobuf/internal/encoding/text
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-07-29 17:31:32 +0200
committerGitHub <noreply@github.com>2022-07-29 17:31:32 +0200
commit1ea3686600eada7e24e352359e9b76ece1c0bae2 (patch)
tree04bd7464360d0c7cd76ace1cd6f953c1c939cb20 /vendor/google.golang.org/protobuf/internal/encoding/text
parent6e86e572439c0cbbeac5be48d19fbc74e6f31d87 (diff)
parent49bcb7eaa0f3dd14aee629ac0ce8a4e67b954f00 (diff)
downloadpodman-1ea3686600eada7e24e352359e9b76ece1c0bae2.tar.gz
podman-1ea3686600eada7e24e352359e9b76ece1c0bae2.tar.bz2
podman-1ea3686600eada7e24e352359e9b76ece1c0bae2.zip
Merge pull request #15116 from containers/dependabot/go_modules/google.golang.org/protobuf-1.28.1
Bump google.golang.org/protobuf from 1.28.0 to 1.28.1
Diffstat (limited to 'vendor/google.golang.org/protobuf/internal/encoding/text')
-rw-r--r--vendor/google.golang.org/protobuf/internal/encoding/text/decode.go30
-rw-r--r--vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go6
-rw-r--r--vendor/google.golang.org/protobuf/internal/encoding/text/doc.go4
3 files changed, 31 insertions, 9 deletions
diff --git a/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go b/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go
index 37803773f..427c62d03 100644
--- a/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go
+++ b/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go
@@ -8,7 +8,6 @@ import (
"bytes"
"fmt"
"io"
- "regexp"
"strconv"
"unicode/utf8"
@@ -421,7 +420,7 @@ func (d *Decoder) parseFieldName() (tok Token, err error) {
return Token{}, d.newSyntaxError("invalid field number: %s", d.in[:num.size])
}
- return Token{}, d.newSyntaxError("invalid field name: %s", errRegexp.Find(d.in))
+ return Token{}, d.newSyntaxError("invalid field name: %s", errId(d.in))
}
// parseTypeName parses Any type URL or extension field name. The name is
@@ -571,7 +570,7 @@ func (d *Decoder) parseScalar() (Token, error) {
return tok, nil
}
- return Token{}, d.newSyntaxError("invalid scalar value: %s", errRegexp.Find(d.in))
+ return Token{}, d.newSyntaxError("invalid scalar value: %s", errId(d.in))
}
// parseLiteralValue parses a literal value. A literal value is used for
@@ -653,8 +652,29 @@ func consume(b []byte, n int) []byte {
return b
}
-// Any sequence that looks like a non-delimiter (for error reporting).
-var errRegexp = regexp.MustCompile(`^([-+._a-zA-Z0-9\/]+|.)`)
+// errId extracts a byte sequence that looks like an invalid ID
+// (for the purposes of error reporting).
+func errId(seq []byte) []byte {
+ const maxLen = 32
+ for i := 0; i < len(seq); {
+ if i > maxLen {
+ return append(seq[:i:i], "…"...)
+ }
+ r, size := utf8.DecodeRune(seq[i:])
+ if r > utf8.RuneSelf || (r != '/' && isDelim(byte(r))) {
+ if i == 0 {
+ // Either the first byte is invalid UTF-8 or a
+ // delimiter, or the first rune is non-ASCII.
+ // Return it as-is.
+ i = size
+ }
+ return seq[:i:i]
+ }
+ i += size
+ }
+ // No delimiter found.
+ return seq
+}
// isDelim returns true if given byte is a delimiter character.
func isDelim(c byte) bool {
diff --git a/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go b/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go
index f2d90b789..81a5d8c86 100644
--- a/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go
+++ b/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go
@@ -50,8 +50,10 @@ type number struct {
// parseNumber constructs a number object from given input. It allows for the
// following patterns:
-// integer: ^-?([1-9][0-9]*|0[xX][0-9a-fA-F]+|0[0-7]*)
-// float: ^-?((0|[1-9][0-9]*)?([.][0-9]*)?([eE][+-]?[0-9]+)?[fF]?)
+//
+// integer: ^-?([1-9][0-9]*|0[xX][0-9a-fA-F]+|0[0-7]*)
+// float: ^-?((0|[1-9][0-9]*)?([.][0-9]*)?([eE][+-]?[0-9]+)?[fF]?)
+//
// It also returns the number of parsed bytes for the given number, 0 if it is
// not a number.
func parseNumber(input []byte) number {
diff --git a/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go b/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go
index 0ce8d6fb8..7ae6c2a3c 100644
--- a/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go
+++ b/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go
@@ -24,6 +24,6 @@
// the Go implementation should as well.
//
// The text format is almost a superset of JSON except:
-// * message keys are not quoted strings, but identifiers
-// * the top-level value must be a message without the delimiters
+// - message keys are not quoted strings, but identifiers
+// - the top-level value must be a message without the delimiters
package text