Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go get uses XML parser to parse HTML #13683

Closed
tv42 opened this issue Dec 18, 2015 · 1 comment
Closed

cmd/go: go get uses XML parser to parse HTML #13683

tv42 opened this issue Dec 18, 2015 · 1 comment

Comments

@tv42
Copy link

tv42 commented Dec 18, 2015

https://golang.org/cmd/go/ since 687925f
says

The meta tag should appear as early in the file as possible. In particular, it should appear before any raw JavaScript or CSS, to avoid confusing the go command's restricted parser.

This is not sufficient to have the parser work. The actual requirement is that the HTML page has to follow XML rules until the </head> tag, or some such.

HTML5 does not enforce <head>...</head> to be used, and many HTML minifiers strip it out, leading to the same expected attribute name in element error from encoding/xml even if the meta tag is literally right after doctype and title.

go get chitin.io/chitin fails because of this, because I used https://github.com/tdewolff/minify on it. Yet it's perfectly valid HTML5, and the meta tag is near the beginning.

Here's a HTML5 validator being happy with a sample page (different url because /chitin is a 404, but it has the same meta tags):
https://html5.validator.nu/?doc=https%3A%2F%2Fchitin.io%2F&showsource=yes

The HTML:

<!doctype html><title>Chitin – gives structure to your squishy bits</title><meta name=go-import content="chitin.io/chitin git https://github.com/chitin-io/chitin"><style>body{background-color:#ffffea;display:flex;justify-content:center}body>div{flex:1}na ... and so on

See also #8163

@tv42
Copy link
Author

tv42 commented Dec 18, 2015

IRC conversation made me realize it's worth pointing out that by the time the XML parser fails, go get has already successfully seen the meta tag for the import path it is trying to resolve.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants