Browse Source

Merged r20827 from trunk to 4.1-stable (#33846).


git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@20828 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.1.2
Go MAEDA 3 years ago
parent
commit
35f5165c2d
2 changed files with 22 additions and 0 deletions
  1. 9
    0
      public/javascripts/application.js
  2. 13
    0
      test/system/inline_autocomplete_test.rb

+ 9
- 0
public/javascripts/application.js View File

@@ -8,6 +8,12 @@ $.ajaxPrefilter(function (s) {
}
});

function sanitizeHTML(string) {
var temp = document.createElement('span');
temp.textContent = string;
return temp.innerHTML;
}

function checkAll(id, checked) {
$('#'+id).find('input[type=checkbox]:enabled').prop('checked', checked);
}
@@ -1062,6 +1068,9 @@ function inlineAutoComplete(element) {
requireLeadingSpace: true,
selectTemplate: function (issue) {
return '#' + issue.original.id;
},
menuItemTemplate: function (issue) {
return sanitizeHTML(issue.original.label);
}
});


+ 13
- 0
test/system/inline_autocomplete_test.rb View File

@@ -129,4 +129,17 @@ class InlineAutocompleteSystemTest < ApplicationSystemTestCase

page.has_css?('.tribute-container li', minimum: 1)
end

def test_inline_autocomplete_for_issues_should_escape_html_elements
issue = Issue.generate!(subject: 'This issue has a <select> element', project_id: 1, tracker_id: 1)

log_user('jsmith', 'jsmith')
visit 'projects/1/issues/new'

fill_in 'Description', :with => '#This'

within('.tribute-container') do
assert page.has_text? "Bug ##{issue.id}: This issue has a <select> element"
end
end
end

Loading…
Cancel
Save