aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorThomas Boerger <thomas@webhippie.de>2016-03-27 23:26:45 +0200
committerThomas Boerger <thomas@webhippie.de>2016-03-27 23:26:45 +0200
commitb5948f2e715d25ff1221f139a232c8904dd6df6b (patch)
tree8515249e839d999221543fb789e52df9d0eb1eb5 /models
parent79a1bfd9632c40ce3ee15c2dcbb8f322d871ade0 (diff)
downloadgitea-b5948f2e715d25ff1221f139a232c8904dd6df6b.tar.gz
gitea-b5948f2e715d25ff1221f139a232c8904dd6df6b.zip
Made the issues query more secure and simpler
Diffstat (limited to 'models')
-rw-r--r--models/issue.go21
1 files changed, 5 insertions, 16 deletions
diff --git a/models/issue.go b/models/issue.go
index 5727e07b11..f70fd1247b 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -547,27 +547,16 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) {
}
labelIDs := base.StringsToInt64s(strings.Split(opts.Labels, ","))
- if len(labelIDs) > 0 {
- validJoin := false
- queryStr := "issue.id=issue_label.issue_id"
- for _, id := range labelIDs {
- if id == 0 {
- continue
- }
- validJoin = true
- queryStr += " AND issue_label.label_id=" + com.ToStr(id)
- }
- if validJoin {
- sess.Join("INNER", "issue_label", queryStr)
- }
+ if len(labelIDs) > 1 {
+ sess.Join("INNER", "issue_label", "issue.id = issue_label.issue_id").In("issue_label.label_id", labelIDs)
}
if opts.IsMention {
- queryStr := "issue.id=issue_user.issue_id AND issue_user.is_mentioned=1"
+ sess.Join("INNER", "issue_user", "issue.id = issue_user.issue_id AND issue_user.is_mentioned = 1")
+
if opts.UserID > 0 {
- queryStr += " AND issue_user.uid=" + com.ToStr(opts.UserID)
+ sess.Where("issue_user.uid = ?", opts.UserID)
}
- sess.Join("INNER", "issue_user", queryStr)
}
issues := make([]*Issue, 0, setting.IssuePagingNum)