From b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Thu, 11 Feb 2016 16:16:52 +0200 Subject: Godeps: update all dependencies to latest code --- .../src/golang.org/x/net/html/charset/charset.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go') diff --git a/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go b/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go index fd7eb585d..449607253 100644 --- a/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go +++ b/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go @@ -19,17 +19,30 @@ import ( "golang.org/x/net/html" "golang.org/x/text/encoding" "golang.org/x/text/encoding/charmap" + "golang.org/x/text/encoding/htmlindex" "golang.org/x/text/transform" ) // Lookup returns the encoding with the specified label, and its canonical // name. It returns nil and the empty string if label is not one of the // standard encodings for HTML. Matching is case-insensitive and ignores -// leading and trailing whitespace. +// leading and trailing whitespace. Encoders will use HTML escape sequences for +// runes that are not supported by the character set. func Lookup(label string) (e encoding.Encoding, name string) { - label = strings.ToLower(strings.Trim(label, "\t\n\r\f ")) - enc := encodings[label] - return enc.e, enc.name + e, err := htmlindex.Get(label) + if err != nil { + return nil, "" + } + name, _ = htmlindex.Name(e) + return &htmlEncoding{e}, name +} + +type htmlEncoding struct{ encoding.Encoding } + +func (h *htmlEncoding) NewEncoder() *encoding.Encoder { + // HTML requires a non-terminating legacy encoder. We use HTML escapes to + // substitute unsupported code points. + return encoding.HTMLEscapeUnsupported(h.Encoding.NewEncoder()) } // DetermineEncoding determines the encoding of an HTML document by examining -- cgit