shithub: hugo

Download patch

ref: 0c6c98e401b22fa2737bb7266742ae88722825ab
parent: 90c774908530390daa5813fcdd31435999971359
author: Bjørn Erik Pedersen <[email protected]>
date: Sun Jun 3 19:23:48 EDT 2018

tpl/strings: Remove overflow check in strings.Repeat

The test fails on 32 bit systems. Let it panic instead.

--- a/tpl/strings/strings.go
+++ b/tpl/strings/strings.go
@@ -432,8 +432,6 @@
 
 	if sn < 0 {
 		return "", errors.New("strings: negative Repeat count")
-	} else if sn > 0 && len(ss)*sn/sn != len(ss) {
-		return "", errors.New("strings: Repeat count causes overflow")
 	}
 
 	return _strings.Repeat(ss, sn), nil
--- a/tpl/strings/strings_test.go
+++ b/tpl/strings/strings_test.go
@@ -16,7 +16,6 @@
 import (
 	"fmt"
 	"html/template"
-	"math"
 	"testing"
 
 	"github.com/gohugoio/hugo/deps"
@@ -730,7 +729,7 @@
 		// errors
 		{"", tstNoStringer{}, false},
 		{tstNoStringer{}, "", false},
-		{"ab", math.MaxInt64, false},
+		{"ab", -1, false},
 	} {
 		errMsg := fmt.Sprintf("[%d] %v", i, test)