From 48c16de8bf74df0fa94a30d29e2e7e3446d48433 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 15 Aug 2021 00:06:40 +0800 Subject: Improve security and simplify code - Make variable name more semantic - Reduce cyclomatic complexities for the formula calculate function - Support specified unzip size limit on open file options, avoid zip bombs vulnerability attack - Typo fix for documentation and error message --- errors.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'errors.go') diff --git a/errors.go b/errors.go index 0edb697..aee4420 100644 --- a/errors.go +++ b/errors.go @@ -16,26 +16,36 @@ import ( "fmt" ) +// newInvalidColumnNameError defined the error message on receiving the invalid column name. func newInvalidColumnNameError(col string) error { return fmt.Errorf("invalid column name %q", col) } +// newInvalidRowNumberError defined the error message on receiving the invalid row number. func newInvalidRowNumberError(row int) error { return fmt.Errorf("invalid row number %d", row) } +// newInvalidCellNameError defined the error message on receiving the invalid cell name. func newInvalidCellNameError(cell string) error { return fmt.Errorf("invalid cell name %q", cell) } +// newInvalidExcelDateError defined the error message on receiving the data with negative values. func newInvalidExcelDateError(dateValue float64) error { - return fmt.Errorf("invalid date value %f, negative values are not supported supported", dateValue) + return fmt.Errorf("invalid date value %f, negative values are not supported", dateValue) } +// newUnsupportChartType defined the error message on receiving the chart type are unsupported. func newUnsupportChartType(chartType string) error { return fmt.Errorf("unsupported chart type %s", chartType) } +// newUnzipSizeLimitError defined the error message on unzip size exceeds the limit. +func newUnzipSizeLimitError(unzipSizeLimit int64) error { + return fmt.Errorf("unzip size exceeds the %d bytes limit", unzipSizeLimit) +} + var ( // ErrStreamSetColWidth defined the error message on set column width in // stream writing mode. -- cgit v1.2.1