aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortechknowlogick <hello@techknowlogick.com>2018-12-21 09:05:47 -0500
committerGitHub <noreply@github.com>2018-12-21 09:05:47 -0500
commitaf4626a2700aa81ecf4fcf7c81717f6715513526 (patch)
treeea83a1a1c02f50fd205d7a4ee82ad2a05910e354
parent21c70e1ed27420646d0d85f044facc8c84be3d5f (diff)
downloadgitea-af4626a2700aa81ecf4fcf7c81717f6715513526.tar.gz
gitea-af4626a2700aa81ecf4fcf7c81717f6715513526.zip
Immediate fix to htmlEncode user added text (#5575)
There are likely problems remaining with the way that initCommentForm is creating its elements. I suspect that a malformed avatar url could be used maliciously.
-rw-r--r--public/js/index.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/public/js/index.js b/public/js/index.js
index b24da85557..8d22deaa6c 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -1,5 +1,9 @@
'use strict';
+function htmlEncode(text) {
+ return jQuery('<div />').text(text).html()
+}
+
var csrf;
var suburl;
@@ -312,12 +316,12 @@ function initCommentForm() {
switch (input_id) {
case '#milestone_id':
$list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' +
- $(this).text() + '</a>');
+ htmlEncode($(this).text()) + '</a>');
break;
case '#assignee_id':
$list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' +
'<img class="ui avatar image" src=' + $(this).data('avatar') + '>' +
- $(this).text() + '</a>');
+ htmlEncode($(this).text()) + '</a>');
}
$('.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 + '&nbsp;' + issue.title,
+ 'name' : '#' + issue.number + '&nbsp;' + htmlEncode(issue.title),
'value' : issue.id
});
});