Commit 5b085482 authored by Russ Cox's avatar Russ Cox

cmd/go: ignore XML errors after Go <meta> tags

Fixes #13683.

Change-Id: I26afb3ac346beb95624f9032d94a29b5bc7853ef
Reviewed-on: https://go-review.googlesource.com/18051Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 5270b57e
......@@ -43,7 +43,7 @@ func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) {
for {
t, err = d.RawToken()
if err != nil {
if err == io.EOF {
if err == io.EOF || len(imports) > 0 {
err = nil
}
return
......
......@@ -57,6 +57,15 @@ var parseMetaGoImportsTests = []struct {
<body>`,
[]metaImport{{"foo/bar", "git", "https://github.com/rsc/foo/bar"}},
},
{
`<!doctype html><meta name="go-import" content="foo/bar git https://github.com/rsc/foo/bar">`,
[]metaImport{{"foo/bar", "git", "https://github.com/rsc/foo/bar"}},
},
{
// XML doesn't like <div style=position:relative>.
`<!doctype html><title>Page Not Found</title><meta name=go-import content="chitin.io/chitin git https://github.com/chitin-io/chitin"><div style=position:relative>DRAFT</div>`,
[]metaImport{{"chitin.io/chitin", "git", "https://github.com/chitin-io/chitin"}},
},
}
func TestParseMetaGoImports(t *testing.T) {
......
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