Commit 1405d7ecdc989a9046fac7a5de0899c59ffd3aee

Authored by Felix Bünemann
1 parent bd3eb276
Exists in master and in 1 other branch production

Fix double escaping of problem title in list view

Also added a spec to test for double escaping which fails without the
changes to truncated_problem_message.
app/helpers/problems_helper.rb
... ... @@ -6,7 +6,7 @@ module ProblemsHelper
6 6 def truncated_problem_message(problem)
7 7 unless (msg = problem.message).blank?
8 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 10 end
11 11 end
12 12  
... ...
spec/helpers/problems_helper_spec.rb
... ... @@ -8,6 +8,13 @@ describe ProblemsHelper do
8 8 expect(truncated).to be_html_safe
9 9 expect(truncated).to_not include('<', '>')
10 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 18 end
12 19  
13 20 describe "#gravatar_tag" do
... ...