Add checks on ID list values
authorMikael Berthe <mikael@lilotux.net>
Mon, 17 Apr 2017 16:22:56 +0200
changeset 134 588edbc9e14b
parent 133 0085bcfc1131
child 135 c578c80ed882
Add checks on ID list values
account.go
report.go
status.go
--- a/account.go	Mon Apr 17 15:22:45 2017 +0200
+++ b/account.go	Mon Apr 17 16:22:56 2017 +0200
@@ -257,6 +257,9 @@
 
 	params := make(apiCallParams)
 	for i, id := range accountIDs {
+		if id < 1 {
+			return nil, ErrInvalidID
+		}
 		qID := fmt.Sprintf("id[%d]", i+1)
 		params[qID] = strconv.Itoa(id)
 	}
--- a/report.go	Mon Apr 17 15:22:45 2017 +0200
+++ b/report.go	Mon Apr 17 16:22:56 2017 +0200
@@ -32,6 +32,9 @@
 	params["account_id"] = strconv.Itoa(accountID)
 	params["comment"] = comment
 	for i, id := range statusIDs {
+		if id < 1 {
+			return nil, ErrInvalidID
+		}
 		qID := fmt.Sprintf("status_ids[%d]", i+1)
 		params[qID] = strconv.Itoa(id)
 	}
--- a/status.go	Mon Apr 17 15:22:45 2017 +0200
+++ b/status.go	Mon Apr 17 16:22:56 2017 +0200
@@ -97,6 +97,9 @@
 			params["in_reply_to_id"] = strconv.Itoa(opts.InReplyToID)
 		}
 		for i, id := range opts.MediaIDs {
+			if id < 1 {
+				return ErrInvalidID
+			}
 			qID := fmt.Sprintf("media_ids[%d]", i+1)
 			params[qID] = strconv.Itoa(id)
 		}