# frozen_string_literal: true require 'spec_helper' RSpec.describe Gitlab::OtherMarkup, feature_category: :wiki do let(:context) { {} } context 'when restructured text' do it 'renders' do input = <<~RST Header ====== *emphasis*; **strong emphasis**; `interpreted text` RST output = <<~HTML
emphasis; strong emphasis; interpreted text
HTML expect(render('unimportant_name.rst', input, context)).to include(output.strip) end context 'when PlantUML is enabled' do it 'generates the diagram' do Gitlab::CurrentSettings.current_application_settings.update!(plantuml_enabled: true, plantuml_url: 'https://plantuml.com/plantuml') input = <<~RST .. plantuml:: :caption: Caption with **bold** and *italic* Bob -> Alice: hello Alice -> Bob: hi RST output = <<~HTMLCaption with bold and italic
HTML expect(render('unimportant_name.rst', input, context)).to include(output.strip) end end end context 'XSS Checks' do links = { 'links' => { file: 'file.rdoc', input: 'XSS[JaVaScriPt:alert(1)]', output: "\n" + '' + "\n" } } links.each do |name, data| it "does not convert dangerous #{name} into HTML" do expect(render(data[:file], data[:input], context)).to eq(data[:output]) end end end context 'when mediawiki content' do links = { 'p' => { file: 'file.mediawiki', input: 'Red Bridge (JRuby Embed)', output: "\nRed Bridge (JRuby Embed)
" }, 'h1' => { file: 'file.mediawiki', input: '= Red Bridge (JRuby Embed) =', output: "\n\n#{text}
") end end context 'RedCloth markup' do it 'renders textile correctly' do test_text = '"This is *my* text."' expected_res = "“This is my text.”
" expect(RedCloth.new(test_text).to_html).to eq(expected_res) end it 'protects against malicious backtracking' do test_text = '