From ba387764ca1590625d349e74eb8a8a64d1849b67 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 14 Nov 2018 00:00:35 +0200 Subject: Fix things --- vendor/golang.org/x/image/bmp/reader.go | 30 ++++++++++++++++++++++-------- vendor/golang.org/x/image/tiff/reader.go | 2 +- vendor/golang.org/x/image/vp8/decode.go | 4 ++-- vendor/golang.org/x/image/webp/decode.go | 2 -- vendor/golang.org/x/image/webp/doc.go | 9 +++++++++ vendor/golang.org/x/image/webp/webp.go | 30 ------------------------------ vendor/golang.org/x/net/html/const.go | 10 +++++++++- vendor/golang.org/x/net/html/parse.go | 29 +++++++++++++++++++++++------ 8 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 vendor/golang.org/x/image/webp/doc.go delete mode 100644 vendor/golang.org/x/image/webp/webp.go (limited to 'vendor/golang.org') diff --git a/vendor/golang.org/x/image/bmp/reader.go b/vendor/golang.org/x/image/bmp/reader.go index a0f2715..c10a022 100644 --- a/vendor/golang.org/x/image/bmp/reader.go +++ b/vendor/golang.org/x/image/bmp/reader.go @@ -137,20 +137,26 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b // We only support those BMP images that are a BITMAPFILEHEADER // immediately followed by a BITMAPINFOHEADER. const ( - fileHeaderLen = 14 - infoHeaderLen = 40 + fileHeaderLen = 14 + infoHeaderLen = 40 + v4InfoHeaderLen = 108 + v5InfoHeaderLen = 124 ) var b [1024]byte - if _, err := io.ReadFull(r, b[:fileHeaderLen+infoHeaderLen]); err != nil { + if _, err := io.ReadFull(r, b[:fileHeaderLen+4]); err != nil { return image.Config{}, 0, false, err } if string(b[:2]) != "BM" { return image.Config{}, 0, false, errors.New("bmp: invalid format") } offset := readUint32(b[10:14]) - if readUint32(b[14:18]) != infoHeaderLen { + infoLen := readUint32(b[14:18]) + if infoLen != infoHeaderLen && infoLen != v4InfoHeaderLen && infoLen != v5InfoHeaderLen { return image.Config{}, 0, false, ErrUnsupported } + if _, err := io.ReadFull(r, b[fileHeaderLen+4:fileHeaderLen+infoLen]); err != nil { + return image.Config{}, 0, false, err + } width := int(int32(readUint32(b[18:22]))) height := int(int32(readUint32(b[22:26]))) if height < 0 { @@ -159,14 +165,22 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b if width < 0 || height < 0 { return image.Config{}, 0, false, ErrUnsupported } - // We only support 1 plane, 8 or 24 bits per pixel and no compression. + // We only support 1 plane and 8, 24 or 32 bits per pixel and no + // compression. planes, bpp, compression := readUint16(b[26:28]), readUint16(b[28:30]), readUint32(b[30:34]) + // if compression is set to BITFIELDS, but the bitmask is set to the default bitmask + // that would be used if compression was set to 0, we can continue as if compression was 0 + if compression == 3 && infoLen > infoHeaderLen && + readUint32(b[54:58]) == 0xff0000 && readUint32(b[58:62]) == 0xff00 && + readUint32(b[62:66]) == 0xff && readUint32(b[66:70]) == 0xff000000 { + compression = 0 + } if planes != 1 || compression != 0 { return image.Config{}, 0, false, ErrUnsupported } switch bpp { case 8: - if offset != fileHeaderLen+infoHeaderLen+256*4 { + if offset != fileHeaderLen+infoLen+256*4 { return image.Config{}, 0, false, ErrUnsupported } _, err = io.ReadFull(r, b[:256*4]) @@ -181,12 +195,12 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b } return image.Config{ColorModel: pcm, Width: width, Height: height}, 8, topDown, nil case 24: - if offset != fileHeaderLen+infoHeaderLen { + if offset != fileHeaderLen+infoLen { return image.Config{}, 0, false, ErrUnsupported } return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 24, topDown, nil case 32: - if offset != fileHeaderLen+infoHeaderLen { + if offset != fileHeaderLen+infoLen { return image.Config{}, 0, false, ErrUnsupported } return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 32, topDown, nil diff --git a/vendor/golang.org/x/image/tiff/reader.go b/vendor/golang.org/x/image/tiff/reader.go index 8a941c1..ce2ef71 100644 --- a/vendor/golang.org/x/image/tiff/reader.go +++ b/vendor/golang.org/x/image/tiff/reader.go @@ -110,7 +110,7 @@ func (d *decoder) ifdUint(p []byte) (u []uint, err error) { return u, nil } -// parseIFD decides whether the the IFD entry in p is "interesting" and +// parseIFD decides whether the IFD entry in p is "interesting" and // stows away the data in the decoder. It returns the tag number of the // entry and an error, if any. func (d *decoder) parseIFD(p []byte) (int, error) { diff --git a/vendor/golang.org/x/image/vp8/decode.go b/vendor/golang.org/x/image/vp8/decode.go index 1bb5028..2aa9fee 100644 --- a/vendor/golang.org/x/image/vp8/decode.go +++ b/vendor/golang.org/x/image/vp8/decode.go @@ -82,7 +82,7 @@ type mb struct { pred [4]uint8 // nzMask is a mask of 8 bits: 4 for the bottom or right 4x4 luma regions, // and 2 + 2 for the bottom or right 4x4 chroma regions. A 1 bit indicates - // that that region has non-zero coefficients. + // that region has non-zero coefficients. nzMask uint8 // nzY16 is a 0/1 value that is 1 if the macroblock used Y16 prediction and // had non-zero coefficients. @@ -274,7 +274,7 @@ func (d *Decoder) parseOtherPartitions() error { var partLens [maxNOP]int d.nOP = 1 << d.fp.readUint(uniformProb, 2) - // The final partition length is implied by the the remaining chunk data + // The final partition length is implied by the remaining chunk data // (d.r.n) and the other d.nOP-1 partition lengths. Those d.nOP-1 partition // lengths are stored as 24-bit uints, i.e. up to 16 MiB per partition. n := 3 * (d.nOP - 1) diff --git a/vendor/golang.org/x/image/webp/decode.go b/vendor/golang.org/x/image/webp/decode.go index 111f358..f77a4eb 100644 --- a/vendor/golang.org/x/image/webp/decode.go +++ b/vendor/golang.org/x/image/webp/decode.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build go1.6 - package webp import ( diff --git a/vendor/golang.org/x/image/webp/doc.go b/vendor/golang.org/x/image/webp/doc.go new file mode 100644 index 0000000..e321c85 --- /dev/null +++ b/vendor/golang.org/x/image/webp/doc.go @@ -0,0 +1,9 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package webp implements a decoder for WEBP images. +// +// WEBP is defined at: +// https://developers.google.com/speed/webp/docs/riff_container +package webp // import "golang.org/x/image/webp" diff --git a/vendor/golang.org/x/image/webp/webp.go b/vendor/golang.org/x/image/webp/webp.go deleted file mode 100644 index 850cdc8..0000000 --- a/vendor/golang.org/x/image/webp/webp.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package webp implements a decoder for WEBP images. -// -// WEBP is defined at: -// https://developers.google.com/speed/webp/docs/riff_container -// -// It requires Go 1.6 or later. -package webp // import "golang.org/x/image/webp" - -// This blank Go file, other than the package clause, exists so that this -// package can be built for Go 1.5 and earlier. (The other files in this -// package are all marked "+build go1.6" for the NYCbCrA types introduced in Go -// 1.6). There is no functionality in a blank package, but some image -// manipulation programs might still underscore import this package for the -// side effect of registering the WEBP format with the standard library's -// image.RegisterFormat and image.Decode functions. For example, that program -// might contain: -// -// // Underscore imports to register some formats for image.Decode. -// import _ "image/gif" -// import _ "image/jpeg" -// import _ "image/png" -// import _ "golang.org/x/image/webp" -// -// Such a program will still compile for Go 1.5 (due to this placeholder Go -// file). It will simply not be able to recognize and decode WEBP (but still -// handle GIF, JPEG and PNG). diff --git a/vendor/golang.org/x/net/html/const.go b/vendor/golang.org/x/net/html/const.go index 5eb7c5a..a3a918f 100644 --- a/vendor/golang.org/x/net/html/const.go +++ b/vendor/golang.org/x/net/html/const.go @@ -97,8 +97,16 @@ func isSpecialElement(element *Node) bool { switch element.Namespace { case "", "html": return isSpecialElementMap[element.Data] + case "math": + switch element.Data { + case "mi", "mo", "mn", "ms", "mtext", "annotation-xml": + return true + } case "svg": - return element.Data == "foreignObject" + switch element.Data { + case "foreignObject", "desc", "title": + return true + } } return false } diff --git a/vendor/golang.org/x/net/html/parse.go b/vendor/golang.org/x/net/html/parse.go index 4b1fa42..64a5793 100644 --- a/vendor/golang.org/x/net/html/parse.go +++ b/vendor/golang.org/x/net/html/parse.go @@ -470,6 +470,10 @@ func (p *parser) resetInsertionMode() { case a.Table: p.im = inTableIM case a.Template: + // TODO: remove this divergence from the HTML5 spec. + if n.Namespace != "" { + continue + } p.im = p.templateStack.top() case a.Head: // TODO: remove this divergence from the HTML5 spec. @@ -984,6 +988,14 @@ func inBodyIM(p *parser) bool { p.acknowledgeSelfClosingTag() p.popUntil(buttonScope, a.P) p.parseImpliedToken(StartTagToken, a.Form, a.Form.String()) + if p.form == nil { + // NOTE: The 'isindex' element has been removed, + // and the 'template' element has not been designed to be + // collaborative with the index element. + // + // Ignore the token. + return true + } if action != "" { p.form.Attr = []Attribute{{Key: "action", Val: action}} } @@ -1252,12 +1264,6 @@ func (p *parser) inBodyEndTagFormatting(tagAtom a.Atom) { switch commonAncestor.DataAtom { case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr: p.fosterParent(lastNode) - case a.Template: - // TODO: remove namespace checking - if commonAncestor.Namespace == "html" { - commonAncestor = commonAncestor.LastChild - } - fallthrough default: commonAncestor.AppendChild(lastNode) } @@ -2209,6 +2215,15 @@ func (p *parser) parse() error { } // Parse returns the parse tree for the HTML from the given Reader. +// +// It implements the HTML5 parsing algorithm +// (https://html.spec.whatwg.org/multipage/syntax.html#tree-construction), +// which is very complicated. The resultant tree can contain implicitly created +// nodes that have no explicit listed in r's data, and nodes' parents can +// differ from the nesting implied by a naive processing of start and end +// s. Conversely, explicit s in r's data can be silently dropped, +// with no corresponding node in the resulting tree. +// // The input is assumed to be UTF-8 encoded. func Parse(r io.Reader) (*Node, error) { p := &parser{ @@ -2230,6 +2245,8 @@ func Parse(r io.Reader) (*Node, error) { // ParseFragment parses a fragment of HTML and returns the nodes that were // found. If the fragment is the InnerHTML for an existing element, pass that // element in context. +// +// It has the same intricacies as Parse. func ParseFragment(r io.Reader, context *Node) ([]*Node, error) { contextTag := "" if context != nil { -- cgit v1.2.3