Skip to content

Commit 622fdfe

Browse files
committed
Fix XSS, tests, and rubocop
1 parent 10bd7f9 commit 622fdfe

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

app/controllers/complaints_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def show
5757
private
5858

5959
def access_check(complaint)
60+
# rubocop:disable Lint/DuplicateBranch
6061
if user_signed_in? && (current_user.staff? || current_user == complaint.user)
6162
# only allow complainants to access their own complaints regardless of access token
6263
true
@@ -66,5 +67,6 @@ def access_check(complaint)
6667
else
6768
raise ActiveRecord::RecordNotFound
6869
end
70+
# rubocop:enable Lint/DuplicateBranch
6971
end
7072
end

app/models/complaint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def update_status(new_status, attribute_to = nil)
2020
attribution = attribute_to.nil? ? 'automatically' : "by #{attribute_to}"
2121
comments.create(content: "Status updated to #{new_status} at #{dt.iso8601} #{attribution}.", internal: true,
2222
user_id: -1)
23-
# TODO send email
23+
# TODO: send email
2424
end
2525

2626
private

app/views/complaints/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="grid--cell is-3">Reported URL</div>
1313
<div class="grid--cell is-9 has-color-yellow-700">
1414
<i class="fas fa-exclamation-triangle"></i>
15-
<%= link_to @complaint.reported_url, @complaint.reported_url, class: 'is-yellow' %>
15+
<%= sanitize(link_to(@complaint.reported_url, @complaint.reported_url, class: 'is-yellow')) %>
1616
</div>
1717

1818
<% if @content_type.present? %>

test/controllers/complaints_controller_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ComplaintsControllerTest < ActionDispatch::IntegrationTest
4343
content: 'test', email: 'something@else.com', user_wants_updates: true
4444
assert_response(:found)
4545
assert_not_nil assigns(:complaint)
46-
assert_redirected_to complaint_path(@complaint.access_token)
46+
assert_redirected_to complaint_path(assigns(:complaint).access_token)
4747
assert_equal users(:basic_user).email, assigns(:complaint).email
4848
end
4949

@@ -52,7 +52,7 @@ class ComplaintsControllerTest < ActionDispatch::IntegrationTest
5252
content: 'test', email: 'something@else.com', user_wants_updates: true
5353
assert_response(:found)
5454
assert_not_nil assigns(:complaint)
55-
assert_redirected_to complaint_path(@complaint.access_token)
55+
assert_redirected_to complaint_path(assigns(:complaint).access_token)
5656
assert_equal 'something@else.com', assigns(:complaint).email
5757
end
5858

0 commit comments

Comments
 (0)