Commit de4b0655 authored by Nigel Tao's avatar Nigel Tao

image/png: allow tRNS chunk without a PLTE chunk.

While https://www.w3.org/TR/PNG/#5ChunkOrdering says that tRNS's
ordering constraint is "After PLTE; before IDAT", it is legal for a tRNS
chunk to occur without a PLTE chunk at all, for greyscale and truecolor
transparency as opposed to palette-based transparency. See
https://www.w3.org/TR/PNG/#11transinfo

Fixes #17511.

Change-Id: I047b0b01d78a1cda65e00eeac229bb972cda431d
Reviewed-on: https://go-review.googlesource.com/32139Reviewed-by: default avatarRob Pike <r@golang.org>
parent 645e984f
...@@ -709,9 +709,13 @@ func (d *decoder) parseChunk() error { ...@@ -709,9 +709,13 @@ func (d *decoder) parseChunk() error {
d.stage = dsSeenPLTE d.stage = dsSeenPLTE
return d.parsePLTE(length) return d.parsePLTE(length)
case "tRNS": case "tRNS":
if cbPaletted(d.cb) {
if d.stage != dsSeenPLTE { if d.stage != dsSeenPLTE {
return chunkOrderError return chunkOrderError
} }
} else if d.stage != dsSeenIHDR {
return chunkOrderError
}
d.stage = dsSeentRNS d.stage = dsSeentRNS
return d.parsetRNS(length) return d.parsetRNS(length)
case "IDAT": case "IDAT":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment