Sha256: c584f586082adcc7e925d4e3b5d3f68cdc684b1fa187eec4828149a6e7742ab1

Contents?: true

Size: 1.64 KB

Versions: 24

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe Netsparker::Vulnerability do
  let(:doc) { described_class.new(nil) }

  describe '#cleanup_html' do
    it 'formats the html special characters' do
      sample = "<doc>&quot;&amp;&lt;&gt;&#39;</doc>"
      expected = "<doc>\"&<>\'</doc>"
      expect(doc.send(:cleanup_html, sample)).to eq(expected)
    end

    it 'outputs the CDATA text' do
      sample = "<doc><![CDATA[Sample Text]]></doc>"

      expected = "<doc>Sample Text</doc>"
      expect(doc.send(:cleanup_html, sample)).to eq(expected)
    end

    it 're-formats the html formatting tags to textile' do
      sample = "<doc>"\
        "<b>Bold</b>\n"\
        "<i>Italic</i>\n"\
        "<em>Emphasis</em>\n"\
        "<h2>Header</h2>\n"\
        "<strong>Strong</strong>\n"\
        "</doc>"

      expected = "<doc>*Bold*\n_Italic_\n*Emphasis*\n*Header*\n*Strong*\n</doc>"
      expect(doc.send(:cleanup_html, sample)).to eq(expected)
    end

    it 're-format the html link to textile' do
      sample = "<doc>"\
        "<a href='https://drad.is'>DradisLink1</a>\n"\
        "<a target='_blank' href='https://drad.is'><i class='icon-external-link'></i>DradisLink2</a>\n"\
        "<a href=\"https://drad.is\">DradisLink3</a>\n"\
        "<a href=\"https://drad.is\" class='rspec'>DradisLink4</a>\n"\
        "</doc>"

      expected = "<doc>"\
                   "\"DradisLink1\":https://drad.is\n"\
                   "\"DradisLink2\":https://drad.is\n"\
                   "\"DradisLink3\":https://drad.is\n"\
                   "\"DradisLink4\":https://drad.is\n"\
                 "</doc>"
      expect(doc.send(:cleanup_html, sample)).to eq(expected)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
dradis-netsparker-3.18.0 spec/vulnerability_spec.rb
dradis-netsparker-3.17.0 spec/vulnerability_spec.rb
dradis-netsparker-3.16.0 spec/vulnerability_spec.rb
dradis-netsparker-3.15.0 spec/vulnerability_spec.rb