Module: XmlSanitizer

Defined in:
lib/xml_sanitizer.rb,
lib/xml_sanitizer/version.rb,
lib/xml_sanitizer/default_permit_scrubber.rb

Defined Under Namespace

Classes: DefaultPermitScrubber

Constant Summary collapse

VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.sanitize(xml:, scrubber: DefaultPermitScrubber.new) ⇒ Object Also known as: sanitize_document



9
10
11
12
13
14
# File 'lib/xml_sanitizer.rb', line 9

def sanitize(xml:, scrubber: DefaultPermitScrubber.new)
  xml_document = Loofah.xml_document(xml)

  xml_document.scrub!(scrubber)
  xml_document.to_xml
end

.sanitize_fragment(xml:, scrubber: DefaultPermitScrubber.new) ⇒ Object



18
19
20
21
22
23
# File 'lib/xml_sanitizer.rb', line 18

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

  xml_fragment.scrub!(scrubber)
  xml_fragment.to_xml
end