From 240a0d3ad220bea387d009616f9588cdaf8946ec Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Sat, 9 Jun 2018 14:20:14 -0500 Subject: [PATCH] Simple check for empty columns in CSV import to prevent crashes --- util/util.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/util.go b/util/util.go index a933c0dd..ac1db418 100644 --- a/util/util.go +++ b/util/util.go @@ -91,20 +91,20 @@ func ParseCSV(r *http.Request) ([]models.Target, error) { if err == io.EOF { break } - if fi != -1 { + if fi != -1 && len(record) > fi { fn = record[fi] } - if li != -1 { + if li != -1 && len(record) > li { ln = record[li] } - if ei != -1 { + if ei != -1 && len(record) > ei { csvEmail, err := mail.ParseAddress(record[ei]) if err != nil { continue } ea = csvEmail.Address } - if pi != -1 { + if pi != -1 && len(record) > pi { ps = record[pi] } t := models.Target{