Sha256: d734c2c7437d87eafa44553582a6b995b1cd1ad9be27f95e0ee047ba24be0870

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

require 'loofah'
require_relative 'xml_sanitizer/version'
require_relative 'xml_sanitizer/default_permit_scrubber'

module XmlSanitizer
  class << self
    def sanitize(xml:, scrubber: DefaultPermitScrubber.new)
      xml_document = Loofah.xml_document(xml)

      xml_document.scrub!(scrubber)
      xml_document.to_xml
    end

    alias sanitize_document sanitize

    def sanitize_fragment(xml:, scrubber: DefaultPermitScrubber.new)
      xml_fragment = Loofah.xml_fragment(xml)

      xml_fragment.scrub!(scrubber)
      xml_fragment.to_xml
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xml_sanitizer-0.1.0 lib/xml_sanitizer.rb