func Validate in digest doesn't filter no-hex data
This commit is contained in:
parent
91403c1b52
commit
04e6cc37fa
1 changed files with 5 additions and 1 deletions
|
@ -47,7 +47,7 @@ func NewDigestFromHex(alg, hex string) Digest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DigestRegexp matches valid digest types.
|
// DigestRegexp matches valid digest types.
|
||||||
var DigestRegexp = regexp.MustCompile(`[a-zA-Z0-9-_+.]+:[a-zA-Z0-9-_+.=]+`)
|
var DigestRegexp = regexp.MustCompile(`[a-zA-Z0-9-_+.]+:[a-fA-F0-9-_+.=]+$`)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrDigestInvalidFormat returned when digest format invalid.
|
// ErrDigestInvalidFormat returned when digest format invalid.
|
||||||
|
@ -112,6 +112,10 @@ func (d Digest) Validate() error {
|
||||||
|
|
||||||
// Continue on for general parser
|
// Continue on for general parser
|
||||||
|
|
||||||
|
if !DigestRegexp.MatchString(s) {
|
||||||
|
return ErrDigestInvalidFormat
|
||||||
|
}
|
||||||
|
|
||||||
i := strings.Index(s, ":")
|
i := strings.Index(s, ":")
|
||||||
if i < 0 {
|
if i < 0 {
|
||||||
return ErrDigestInvalidFormat
|
return ErrDigestInvalidFormat
|
||||||
|
|
Loading…
Reference in a new issue