Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: sniff.go DetectContentType failing to detect text/html correctly #16275
Please answer these questions before submitting your issue. Thanks!
With test.html being:
output: Content-type text/plain; charset=utf-8
output: Content-type text/html; charset=utf-8
Basically DetectContentType should detect the '<!--' at the start of the .html file, and it does not. As soon as I remove the '<!--' tag, then the file is correctly detected as text/html
Content-type text/plain; charset=utf-8
A valid HTML, XHTML, XML, or HTML4 document must not start with anything
On Wed, Jul 6, 2016 at 11:25 PM, Michael Fraenkel firstname.lastname@example.org
ok you can take the spec / standard high road on this, or we could improve the code. right now, '<!--' is considered text/html (from sniff.go):
The issue is in this line of htmlSig:
My html files do not have a trailing ' ' against '<!--', they have a newline instead.
We're going to follow the spec. If we don't draw the line somewhere then DetectContentType will be under constant churn and feature requests.
Please file a bug at https://github.com/whatwg/mimesniff/issues if you disagree with the spec. Once fixed upstream, we'll fix Go.
Until then, unless there's some place where we're in violation of the mimesniff spec, I'm going to close this bug.