Module: Loofah
- Defined in:
- lib/loofah.rb,
lib/loofah/helpers.rb,
lib/loofah/elements.rb,
lib/loofah/scrubber.rb,
lib/loofah/scrubbers.rb,
lib/loofah/html5/scrub.rb,
lib/loofah/metahelpers.rb,
lib/loofah/xml/document.rb,
lib/loofah/html/document.rb,
lib/loofah/html5/safelist.rb,
lib/loofah/instance_methods.rb,
lib/loofah/xml/document_fragment.rb,
lib/loofah/html/document_fragment.rb,
lib/loofah/html5/libxml2_workarounds.rb
Overview
Strings and IO Objects as Input
Loofah.document and Loofah.fragment accept any IO object in addition to accepting a string. That IO object could be a file, or a socket, or a StringIO, or anything that responds to read
and close
. Which makes it particularly easy to sanitize mass quantities of docs.
Defined Under Namespace
Modules: DocumentDecorator, Elements, HTML, HTML5, Helpers, LibxmlWorkarounds, MetaHelpers, ScrubBehavior, Scrubbers, TextBehavior, XML Classes: Scrubber, ScrubberNotFound
Constant Summary collapse
- VERSION =
The version of Loofah you are using
"2.4.0"
Class Method Summary collapse
-
.document(*args, &block) ⇒ Object
Shortcut for Loofah::HTML::Document.parse This method accepts the same parameters as Nokogiri::HTML::Document.parse.
-
.fragment(*args, &block) ⇒ Object
Shortcut for Loofah::HTML::DocumentFragment.parse This method accepts the same parameters as Nokogiri::HTML::DocumentFragment.parse.
-
.remove_extraneous_whitespace(string) ⇒ Object
A helper to remove extraneous whitespace from text-ified HTML.
-
.scrub_document(string_or_io, method) ⇒ Object
Shortcut for Loofah.document(string_or_io).scrub!(method).
-
.scrub_fragment(string_or_io, method) ⇒ Object
Shortcut for Loofah.fragment(string_or_io).scrub!(method).
-
.scrub_xml_document(string_or_io, method) ⇒ Object
Shortcut for Loofah.xml_document(string_or_io).scrub!(method).
-
.scrub_xml_fragment(string_or_io, method) ⇒ Object
Shortcut for Loofah.xml_fragment(string_or_io).scrub!(method).
-
.xml_document(*args, &block) ⇒ Object
Shortcut for Loofah::XML::Document.parse This method accepts the same parameters as Nokogiri::XML::Document.parse.
-
.xml_fragment(*args, &block) ⇒ Object
Shortcut for Loofah::XML::DocumentFragment.parse This method accepts the same parameters as Nokogiri::XML::DocumentFragment.parse.
Class Method Details
.document(*args, &block) ⇒ Object
Shortcut for Loofah::HTML::Document.parse This method accepts the same parameters as Nokogiri::HTML::Document.parse
37 38 39 |
# File 'lib/loofah.rb', line 37 def document(*args, &block) Loofah::HTML::Document.parse(*args, &block) end |
.fragment(*args, &block) ⇒ Object
Shortcut for Loofah::HTML::DocumentFragment.parse This method accepts the same parameters as Nokogiri::HTML::DocumentFragment.parse
43 44 45 |
# File 'lib/loofah.rb', line 43 def fragment(*args, &block) Loofah::HTML::DocumentFragment.parse(*args, &block) end |
.remove_extraneous_whitespace(string) ⇒ Object
A helper to remove extraneous whitespace from text-ified HTML
80 81 82 |
# File 'lib/loofah.rb', line 80 def remove_extraneous_whitespace(string) string.gsub(/\n\s*\n\s*\n/, "\n\n") end |
.scrub_document(string_or_io, method) ⇒ Object
Shortcut for Loofah.document(string_or_io).scrub!(method)
53 54 55 |
# File 'lib/loofah.rb', line 53 def scrub_document(string_or_io, method) Loofah.document(string_or_io).scrub!(method) end |
.scrub_fragment(string_or_io, method) ⇒ Object
Shortcut for Loofah.fragment(string_or_io).scrub!(method)
48 49 50 |
# File 'lib/loofah.rb', line 48 def scrub_fragment(string_or_io, method) Loofah.fragment(string_or_io).scrub!(method) end |
.scrub_xml_document(string_or_io, method) ⇒ Object
Shortcut for Loofah.xml_document(string_or_io).scrub!(method)
75 76 77 |
# File 'lib/loofah.rb', line 75 def scrub_xml_document(string_or_io, method) Loofah.xml_document(string_or_io).scrub!(method) end |
.scrub_xml_fragment(string_or_io, method) ⇒ Object
Shortcut for Loofah.xml_fragment(string_or_io).scrub!(method)
70 71 72 |
# File 'lib/loofah.rb', line 70 def scrub_xml_fragment(string_or_io, method) Loofah.xml_fragment(string_or_io).scrub!(method) end |
.xml_document(*args, &block) ⇒ Object
Shortcut for Loofah::XML::Document.parse This method accepts the same parameters as Nokogiri::XML::Document.parse
59 60 61 |
# File 'lib/loofah.rb', line 59 def xml_document(*args, &block) Loofah::XML::Document.parse(*args, &block) end |
.xml_fragment(*args, &block) ⇒ Object
Shortcut for Loofah::XML::DocumentFragment.parse This method accepts the same parameters as Nokogiri::XML::DocumentFragment.parse
65 66 67 |
# File 'lib/loofah.rb', line 65 def xml_fragment(*args, &block) Loofah::XML::DocumentFragment.parse(*args, &block) end |