Commit 0d7395af3d2b3b247f4d3c0dd545e7fab58c5819

Authored by Arthur Nogueira Neves
2 parents 4b1f2b15 1405d7ec
Exists in master and in 1 other branch production

Merge pull request #791 from felixbuenemann/fix-problem-title-double-escape

Fix double escaping of problem title in list view
app/helpers/problems_helper.rb
@@ -6,7 +6,7 @@ module ProblemsHelper @@ -6,7 +6,7 @@ module ProblemsHelper
6 def truncated_problem_message(problem) 6 def truncated_problem_message(problem)
7 unless (msg = problem.message).blank? 7 unless (msg = problem.message).blank?
8 # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule 8 # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule
9 - truncate(msg, :length => 300).scan(/.{1,5}/).map { |s| h(s) }.join("​").html_safe 9 + truncate(msg, :length => 300, :escape => false).scan(/.{1,5}/).map { |s| h(s) }.join("​").html_safe
10 end 10 end
11 end 11 end
12 12
spec/helpers/problems_helper_spec.rb
@@ -8,6 +8,13 @@ describe ProblemsHelper do @@ -8,6 +8,13 @@ describe ProblemsHelper do
8 expect(truncated).to be_html_safe 8 expect(truncated).to be_html_safe
9 expect(truncated).to_not include('<', '>') 9 expect(truncated).to_not include('<', '>')
10 end 10 end
  11 +
  12 + it 'does not double escape html' do
  13 + problem = double('problem', :message => '#<NoMethodError: ...>')
  14 + truncated = helper.truncated_problem_message(problem)
  15 + expect(truncated).to be_html_safe
  16 + expect(truncated).to_not include('&amp;')
  17 + end
11 end 18 end
12 19
13 describe "#gravatar_tag" do 20 describe "#gravatar_tag" do