Commit e1d0a0f029efad1aef706e9fb72808e2e3b90ff6

Authored by lest
1 parent 51acf14c
Exists in master and in 1 other branch production

add html escape to truncate_err_message helper, also fix typo in helper name

app/helpers/errs_helper.rb
... ... @@ -7,10 +7,10 @@ module ErrsHelper
7 7 Errbit::Config.confirm_resolve_err === false ? nil : 'Seriously?'
8 8 end
9 9  
10   - def trucated_err_message(problem)
  10 + def truncated_err_message(problem)
11 11 unless (msg = problem.message).blank?
12 12 # Truncate & insert invisible chars so that firefox can emulate 'word-wrap: break-word' CSS rule
13   - truncate(msg, :length => 300).scan(/.{1,5}/).join("​").html_safe
  13 + truncate(msg, :length => 300).scan(/.{1,5}/).map { |s| h(s) }.join("​").html_safe
14 14 end
15 15 end
16 16 end
... ...
app/views/errs/_table.html.haml
... ... @@ -24,7 +24,7 @@
24 24 - else
25 25 %span.environment= link_to problem.environment, app_path(problem.app, :environment => problem.environment)
26 26 %td.message
27   - = link_to trucated_err_message(problem), app_err_path(problem.app, problem)
  27 + = link_to truncated_err_message(problem), app_err_path(problem.app, problem)
28 28 %em= problem.where
29 29 - if problem.comments_count > 0
30 30 - comment = problem.comments.last
... ...
spec/helpers/errs_helper_spec.rb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +require 'spec_helper'
  2 +
  3 +describe ErrsHelper do
  4 + describe '#truncated_err_message' do
  5 + it 'is html safe' do
  6 + problem = double('problem', :message => '#<NoMethodError: ...>')
  7 + truncated = helper.truncated_err_message(problem)
  8 + truncated.should be_html_safe
  9 + truncated.should_not include('<', '>')
  10 + end
  11 + end
  12 +end
... ...