Skip to content

Commit

Permalink
webp: don't reject VP8X that isn't just VP8 + alpha
Browse files Browse the repository at this point in the history
We already support VP8 + alpha, but reject e.g. VP8 + EXIF. After this
commit, we still don't implement VP8 + EXIF (or ANIM, ICCP, etc.), but
we now silently ignore the EXIF chunk instead of rejecting it.

Fixes golang/go#25738, golang/go#38341

Change-Id: I4e9cdb718f0768f34336eab9528b82d2c40a3ee1
GitHub-Last-Rev: a0c2e53
GitHub-Pull-Request: golang#5
Reviewed-on: https://go-review.googlesource.com/c/image/+/249445
Trust: David Symonds <dsymonds@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
  • Loading branch information
narrowizard authored and nigeltao committed Sep 21, 2020
1 parent 972c09e commit 3a743ba
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions webp/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,23 @@ func decode(r io.Reader, configOnly bool) (image.Image, image.Config, error) {
alphaBit = 1 << 4
iccProfileBit = 1 << 5
)
if buf[0] != alphaBit {
return nil, image.Config{}, errors.New("webp: non-Alpha VP8X is not implemented")
}
wantAlpha = (buf[0] & alphaBit) != 0
widthMinusOne = uint32(buf[4]) | uint32(buf[5])<<8 | uint32(buf[6])<<16
heightMinusOne = uint32(buf[7]) | uint32(buf[8])<<8 | uint32(buf[9])<<16
if configOnly {
if wantAlpha {
return nil, image.Config{
ColorModel: color.NYCbCrAModel,
Width: int(widthMinusOne) + 1,
Height: int(heightMinusOne) + 1,
}, nil
}
return nil, image.Config{
ColorModel: color.NYCbCrAModel,
ColorModel: color.YCbCrModel,
Width: int(widthMinusOne) + 1,
Height: int(heightMinusOne) + 1,
}, nil
}
wantAlpha = true

default:
return nil, image.Config{}, errInvalidFormat
}
}
}
Expand Down

0 comments on commit 3a743ba

Please sign in to comment.