diff --git a/public/js/index.js b/public/js/index.js index b24da85557423..8d22deaa6ca39 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,5 +1,9 @@ 'use strict'; +function htmlEncode(text) { + return jQuery('
').text(text).html() +} + var csrf; var suburl; @@ -312,12 +316,12 @@ function initCommentForm() { switch (input_id) { case '#milestone_id': $list.find('.selected').html('' + - $(this).text() + ''); + htmlEncode($(this).text()) + ''); break; case '#assignee_id': $list.find('.selected').html('' + '' + - $(this).text() + ''); + htmlEncode($(this).text()) + ''); } $('.ui' + select_id + '.list .no-select').addClass('hide'); $(input_id).val($(this).data('id')); @@ -1456,7 +1460,7 @@ function searchUsers() { $.each(response.data, function (i, item) { var title = item.login; if (item.full_name && item.full_name.length > 0) { - title += ' (' + item.full_name + ')'; + title += ' (' + htmlEncode(item.full_name) + ')'; } items.push({ title: title, @@ -2510,7 +2514,7 @@ function initTopicbar() { if (res.topics) { formattedResponse.success = true; for (var i=0;i < res.topics.length;i++) { - formattedResponse.results.push({"description": res.topics[i].Name, "data-value":res.topics[i].Name}) + formattedResponse.results.push({"description": res.topics[i].Name, "data-value": res.topics[i].Name}) } } @@ -2631,7 +2635,7 @@ function initIssueList() { // Parse the response from the api to work with our dropdown $.each(response, function(index, issue) { filteredResponse.results.push({ - 'name' : '#' + issue.number + ' ' + issue.title, + 'name' : '#' + issue.number + ' ' + htmlEncode(issue.title), 'value' : issue.id }); });