You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some website documents start with "<!--[if IE]" or "<--comment with no space" and some close it without leaving an actual comment like this: "<!--->".
None of these cases are detected correctly because "<!--" htmlSig is treated like a regular HTML tag when in reality behaves slightly differently.
What version of Go are you using (go version)?
❯ go version
go version go1.10.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
❯ go env
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
package main
import (
"fmt"
"net/http"
)
func main() {
fmt.Println(http.DetectContentType([]byte(`<!--[if !IE]> This has been served from cache <![endif]--><html><body>Hello,world</body></html>`)))
fmt.Println(http.DetectContentType([]byte(`<!-- [if !IE]> This has been served from cache <![endif]--><html><body>Hello,world</body></html>`)))
}
The text was updated successfully, but these errors were encountered:
guliyevemil1
changed the title
net/http: content type detection does not work correctly for HTML comments
net/http: content type detection does not work correctly for some documents that start with HTML comments
Jun 7, 2018
Uh oh!
There was an error while loading. Please reload this page.
Some website documents start with "<!--[if IE]" or "<--comment with no space" and some close it without leaving an actual comment like this: "<!--->".
None of these cases are detected correctly because "<!--" htmlSig is treated like a regular HTML tag when in reality behaves slightly differently.
What version of Go are you using (
go version
)?❯ go version
go version go1.10.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?❯ go env
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
https://play.golang.org/p/f6-N3OA9FGU
What did you expect to see?
text/html; charset=utf-8
text/html; charset=utf-8
What did you see instead?
text/plain; charset=utf-8
text/html; charset=utf-8
The text was updated successfully, but these errors were encountered: