Skip to content

Commit

Permalink
tpl/os: remove 1mb limit for readFile.
Browse files Browse the repository at this point in the history
  • Loading branch information
avdva authored and bep committed Jan 22, 2021
1 parent 32b8607 commit ee9c136
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions tpl/os/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package os
import (
"errors"
"fmt"
"os"
_os "os"

"github.com/gohugoio/hugo/deps"
Expand Down Expand Up @@ -62,22 +61,11 @@ func (ns *Namespace) Getenv(key interface{}) (string, error) {

// readFile reads the file named by filename in the given filesystem
// and returns the contents as a string.
// There is a upper size limit set at 1 megabytes.
func readFile(fs afero.Fs, filename string) (string, error) {
if filename == "" {
return "", errors.New("readFile needs a filename")
}

if info, err := fs.Stat(filename); err == nil {
if info.Size() > 1000000 {
return "", fmt.Errorf("file %q is too big", filename)
}
} else {
if os.IsNotExist(err) {
return "", fmt.Errorf("file %q does not exist", filename)
}
return "", err
}
b, err := afero.ReadFile(fs, filename)
if err != nil {
return "", err
Expand Down

0 comments on commit ee9c136

Please sign in to comment.