forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure brakeman to ignore url safe preview card urls (mastodon#25883)
- Loading branch information
1 parent
94ab71a
commit 2b0bacf
Showing
5 changed files
with
27 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
--- | ||
:skip_checks: | ||
- CheckPermitAttributes | ||
:url_safe_methods: | ||
- url_for_preview_card |
20 changes: 20 additions & 0 deletions
20
spec/views/admin/trends/links/_preview_card.html.haml_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe 'admin/trends/links/_preview_card.html.haml' do | ||
it 'correctly escapes user supplied url values' do | ||
form = instance_double(ActionView::Helpers::FormHelper, check_box: nil) | ||
trend = PreviewCardTrend.new(allowed: false) | ||
preview_card = Fabricate.build( | ||
:preview_card, | ||
url: 'https://host.example/path?query=<script>', | ||
trend: trend, | ||
title: 'Fun' | ||
) | ||
|
||
render partial: 'admin/trends/links/preview_card', locals: { preview_card: preview_card, f: form } | ||
|
||
expect(rendered).to include('<a href="https://host.example/path?query=<script>">Fun</a>') | ||
end | ||
end |