[Fix #1302] sanitize_url can deal with nil values
This commit is contained in:
parent
859de6168b
commit
d945001e0a
2 changed files with 23 additions and 1 deletions
20
spec/helpers/application_helper_spec.rb
Normal file
20
spec/helpers/application_helper_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
describe ApplicationHelper do
|
||||
describe "#sanitize_url" do
|
||||
subject { sanitize_url(url) }
|
||||
|
||||
describe 'does nothing on clean url' do
|
||||
let(:url) { "https://tps.fr/toto" }
|
||||
it { is_expected.to eq(url) }
|
||||
end
|
||||
|
||||
describe 'clean a dangerous url' do
|
||||
let(:url) { "javascript:alert('coucou jtai hacké')" }
|
||||
it { is_expected.to eq(root_url) }
|
||||
end
|
||||
|
||||
describe 'can deal with a nil url' do
|
||||
let(:url) { nil }
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue