]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: ignore XML errors after Go <meta> tags
authorRuss Cox <rsc@golang.org>
Fri, 18 Dec 2015 19:30:12 +0000 (14:30 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 18 Dec 2015 19:51:06 +0000 (19:51 +0000)
Fixes #13683.

Change-Id: I26afb3ac346beb95624f9032d94a29b5bc7853ef
Reviewed-on: https://go-review.googlesource.com/18051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go/discovery.go
src/cmd/go/pkg_test.go

index 4d1df2f4726dc039bb829d5ae3a5fff7b148a150..f6992e9e93e478bdd8318f429b57f967c42cd1f6 100644 (file)
@@ -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
index 23c2e08da19a0fde535be88ab5b393491f5973a2..90a92582e73883dfced2296f93894c9ca094d7ec 100644 (file)
@@ -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) {