Skip to content

Commit

Permalink
func Validate in digest doesn't filter no-hex data
Browse files Browse the repository at this point in the history
  • Loading branch information
xiekeyang committed Mar 5, 2015
1 parent 69d1d7d commit 072e3da
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewDigestFromHex(alg, hex string) Digest {
}

// 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 (
// ErrDigestInvalidFormat returned when digest format invalid.
Expand Down Expand Up @@ -112,6 +112,10 @@ func (d Digest) Validate() error {

// Continue on for general parser

if !DigestRegexp.MatchString(s) {
return ErrDigestInvalidFormat
}

i := strings.Index(s, ":")
if i < 0 {
return ErrDigestInvalidFormat
Expand Down

0 comments on commit 072e3da

Please sign in to comment.