From 8b1d30985c12c0e0f94ad46bb941cf4a8c5c99a8 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 18 Jul 2015 17:58:00 +0200 Subject: Limit page size --- href.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/href.go b/href.go index d06ea40..c68499c 100644 --- a/href.go +++ b/href.go @@ -3,6 +3,7 @@ package main import ( "net/http" "strings" + "errors" "golang.org/x/net/html" ) @@ -28,6 +29,9 @@ func FetchTitle(url string) (string, error) { return "", err } defer resp.Body.Close() + if resp.ContentLength > 8*1024*1024 { + return "", errors.New("content too big") + } doc, err := html.Parse(resp.Body) if err != nil { -- cgit v1.2.3