summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/other_markup.rb
blob: 8f5a353b3810b5df721c54280cdf59b63a572633 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'spec_helper'

describe Gitlab::OtherMarkup, lib: true do
  context "XSS Checks" do
    links = {
      'links' => {
        file: 'file.rdoc',
        input: 'XSS[JaVaScriPt:alert(1)]',
        output: '<p><a>XSS</a></p>'
      }
    }
    links.each do |name, data|
      it "does not convert dangerous #{name} into HTML" do
        expect(render(data[:file], data[:input], context)).to eql data[:output]
      end
    end
  end

  def render(*args)
    described_class.render(*args)
  end
end