2019-08-22 10:57:44 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-09 17:30:06 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 18:09:03 +00:00
|
|
|
RSpec.describe Gitlab::OtherMarkup do
|
2017-04-24 11:57:11 +00:00
|
|
|
let(:context) { {} }
|
|
|
|
|
2017-02-09 17:30:06 +00:00
|
|
|
context "XSS Checks" do
|
|
|
|
links = {
|
|
|
|
'links' => {
|
|
|
|
file: 'file.rdoc',
|
|
|
|
input: 'XSS[JaVaScriPt:alert(1)]',
|
2017-04-24 11:57:11 +00:00
|
|
|
output: "\n" + '<p><a>XSS</a></p>' + "\n"
|
2017-02-09 17:30:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
links.each do |name, data|
|
|
|
|
it "does not convert dangerous #{name} into HTML" do
|
2017-05-02 14:52:19 +00:00
|
|
|
expect(render(data[:file], data[:input], context)).to eq(data[:output])
|
2017-02-09 17:30:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def render(*args)
|
|
|
|
described_class.render(*args)
|
|
|
|
end
|
|
|
|
end
|