diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2018-01-01 09:48:16 +0100 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2018-01-01 09:48:16 +0100 |
commit | e663cdca3df5471ffbf7bfc2d329e7780e5ccf6f (patch) | |
tree | 7245894614a2c5c294cd48047f3d2b2a2cf4ccea /href.go | |
parent | 0d651bca8901257683f5fe366e840bb59f8fd84d (diff) |
10M limit
Diffstat (limited to 'href.go')
-rw-r--r-- | href.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -11,7 +11,10 @@ import ( "golang.org/x/net/html/charset" ) -var errNotHTML = errors.New("Not HTML") +var ( + errNotHTML = errors.New("Not HTML") + errTooBig = errors.New("Content too big") +) func title(n *html.Node) (s string) { if n.Type == html.ElementNode && n.Data == "title" { @@ -40,6 +43,10 @@ func getTitle(uri string) (string, error) { return "", errNotHTML } + if resp.ContentLength > 10*1024*1024 { + return "", errTooBig + } + r, err := charset.NewReader(resp.Body, ct) if err != nil { return "", err |