diff options
author | xuri <xuri.me@gmail.com> | 2021-08-15 00:06:40 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-08-15 00:06:40 +0800 |
commit | 48c16de8bf74df0fa94a30d29e2e7e3446d48433 (patch) | |
tree | 329a2e4ab896982581bd348a1700d75aeb40a517 /errors.go | |
parent | f6f14f507ee1adf4883cb1b12f27932a63afb286 (diff) |
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
Diffstat (limited to 'errors.go')
-rw-r--r-- | errors.go | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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. |