summaryrefslogtreecommitdiff
path: root/file.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-05-29 00:26:40 +0800
committerxuri <xuri.me@gmail.com>2020-05-29 00:26:40 +0800
commit2ae631376b95ff0a59ea18c2c0befcd50135b020 (patch)
treec3542c127aed38cac104c513047327d6316b91d1 /file.go
parentc168233e70db8f220bd07d9d6d277ae9e2a4a73f (diff)
add limits for total columns, row and filename length
Diffstat (limited to 'file.go')
-rw-r--r--file.go4
1 files changed, 4 insertions, 0 deletions
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