Sha256: e2bf2fee5f8c86c91a302f38b5436d1ecf86f33a682513d6eef12a1db0b1944d

Contents?: true

Size: 981 Bytes

Versions: 12

Compression:

Stored size: 981 Bytes

Contents

require 'spec_helper'
require 'softcover/sanitizer'

describe Softcover::Sanitizer do
  context "malicious html" do
    let(:html) { "<div onclick='alert(document.cookie)'></div>"}

    it "cleans xss vectors" do
      expect(subject.clean(html)).to eq "<div></div>"
    end
  end

  context "safe html" do
    let(:html) do <<-EOS
        <div id="a" class="b"></div>
        <div data-tralics-id="c" data-number="d" data-chapter="e"></div>
        <a id="a" class="b" href="c"></a>
        <span id="a" class="b" style="c"></span>
        <ol id="a" class="b"></ol>
        <ul id="a" class="b"></ul>
        <li id="a" class="b"></li>
        <sup id="a" class="b"></sup>
        <h1 id="a" class="b"></h1>
        <h2 id="a" class="b"></h2>
        <h3 id="a" class="b"></h3>
        <img id="a" class="b" src="c" alt="d" />
        <em id="a" class="b"></em>
      EOS
    end

    it "allows class and id" do
      expect(subject.clean(html)).to match html
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
softcover-0.7.0 spec/sanitizer_spec.rb
softcover-0.6.10 spec/sanitizer_spec.rb
softcover-0.6.9 spec/sanitizer_spec.rb
softcover-0.6.7 spec/sanitizer_spec.rb
softcover-0.6.6 spec/sanitizer_spec.rb
softcover-0.6.5 spec/sanitizer_spec.rb
softcover-0.6.4 spec/sanitizer_spec.rb
softcover-0.6.3 spec/sanitizer_spec.rb
softcover-0.6.2 spec/sanitizer_spec.rb
softcover-0.6.1 spec/sanitizer_spec.rb
softcover-0.6.0 spec/sanitizer_spec.rb
softcover-0.5.0 spec/sanitizer_spec.rb