From 2ae631376b95ff0a59ea18c2c0befcd50135b020 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 29 May 2020 00:26:40 +0800 Subject: add limits for total columns, row and filename length --- file.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'file.go') diff --git a/file.go b/file.go index 8fe4115..e8f29da 100644 --- a/file.go +++ b/file.go @@ -12,6 +12,7 @@ package excelize import ( "archive/zip" "bytes" + "errors" "fmt" "io" "os" @@ -62,6 +63,9 @@ func (f *File) Save() error { // SaveAs provides a function to create or update to an xlsx file at the // provided path. func (f *File) SaveAs(name string) error { + if len(name) > FileNameLength { + return errors.New("file name length exceeds maximum limit") + } file, err := os.OpenFile(name, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666) if err != nil { return err -- cgit v1.2.1