summaryrefslogtreecommitdiff
path: root/href.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-01-01 09:48:16 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-01-01 09:48:16 +0100
commite663cdca3df5471ffbf7bfc2d329e7780e5ccf6f (patch)
tree7245894614a2c5c294cd48047f3d2b2a2cf4ccea /href.go
parent0d651bca8901257683f5fe366e840bb59f8fd84d (diff)
10M limit
Diffstat (limited to 'href.go')
-rw-r--r--href.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/href.go b/href.go
index bd4cec6..a4cc5c9 100644
--- a/href.go
+++ b/href.go
@@ -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