Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape error class and error message on failure show page #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/sidekiq/failures/views/failure.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<tr>
<th><%= t('ErrorClass') %></th>
<td>
<code><%= @failure['error_class'] %></code>
<code><%= h @failure['error_class'] %></code>
</td>
</tr>
<tr>
<th><%= t('ErrorMessage') %></th>
<td><%= @failure['error_message'] %></td>
<td><%= h @failure['error_message'] %></td>
</tr>
<% if !@failure['error_backtrace'].nil? %>
<tr>
Expand Down
41 changes: 29 additions & 12 deletions test/web_extension_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,35 @@ def app

describe 'when there is specific failure' do
describe 'with unescaped data' do
before do
create_sample_failure(args: ['<h1>omg</h1>'], error_message: '<p>wow</p>')
get '/failures'
end

it 'can escape arguments' do
last_response.body.must_match(/&quot;&lt;h1&gt;omg&lt;&#x2F;h1&gt;&quot;/)
end

it 'can escape error message' do
last_response.body.must_match(/ArgumentError: &lt;p&gt;wow&lt;&#x2F;p&gt;/)
end
before do
create_sample_failure(args: ['<h1>omg</h1>'], error_message: '<p>wow</p>')
end

describe 'failures index' do
before do
get '/failures'
end
it 'can escape arguments' do
last_response.body.must_match(/&quot;&lt;h1&gt;omg&lt;&#x2F;h1&gt;&quot;/)
end

it 'can escape error message' do
last_response.body.must_match(/ArgumentError: &lt;p&gt;wow&lt;&#x2F;p&gt;/)
end
end

describe 'failures show' do
before do
get "/failures/#{failure_score}"
end
it 'can escape arguments' do
last_response.body.must_match(/&lt;p&gt;wow&lt;&#x2F;p&gt;/)
end

it 'can escape error message' do
last_response.body.must_match(/ArgumentError/)
end
end
end

describe 'with deprecated payload' do
Expand Down