Compare commits

...

1 Commits

Author SHA1 Message Date
T. von Dein
46fde289f5 fix #46: check sort array index before using it for sorting (#48) 2025-12-08 22:30:09 +01:00

View File

@@ -23,8 +23,8 @@ import (
"sort"
"strconv"
"github.com/araddon/dateparse"
"codeberg.org/scip/tablizer/cfg"
"github.com/araddon/dateparse"
)
func sortTable(conf cfg.Config, data *Tabdata) {
@@ -38,6 +38,12 @@ func sortTable(conf cfg.Config, data *Tabdata) {
return
}
for _, column := range conf.UseSortByColumn {
if column > len(data.headers) {
return
}
}
// actual sorting
sort.SliceStable(data.entries, func(i, j int) bool {
// holds the result of a sort of one column