浏览代码

Read one byte of /favicon.ico before using it

That's probably not enough, but at least fixes sites that simply return
an empty response.
Lucas Stadler 9 年之前
父节点
当前提交
8849d4e3e4
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      go/favicon/favicon.go

+ 5 - 0
go/favicon/favicon.go

@ -132,6 +132,11 @@ func GetCanonicalFavicon(u string) (string, error) {
132 132
	if resp.StatusCode >= 400 || resp.Header.Get("Content-Length") == "0" {
133 133
		return "", errors.New("no /favicon.ico")
134 134
	}
135
	buf := make([]byte, 0, 1)
136
	n, err := resp.Body.Read(buf)
137
	if err != nil || n == 0 {
138
		return "", errors.New("can't read /favicon.ico")
139
	}
135 140
	fmt.Println("favicon.ico", resp.Request.URL.String(), faviconUrl)
136 141
	return resp.Request.URL.String(), nil
137 142
}