Class: XmlSanitizer::DefaultPermitScrubber
- Inherits:
-
Loofah::Scrubber
- Object
- Loofah::Scrubber
- XmlSanitizer::DefaultPermitScrubber
- Defined in:
- lib/xml_sanitizer/default_permit_scrubber.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(tags: []) ⇒ DefaultPermitScrubber
constructor
A new instance of DefaultPermitScrubber.
- #namespace_prefix?(node) ⇒ Boolean
- #node_name(node) ⇒ Object
- #node_name_with_namespace_prefix(node) ⇒ Object
- #scrub(node) ⇒ Object
Constructor Details
#initialize(tags: []) ⇒ DefaultPermitScrubber
Returns a new instance of DefaultPermitScrubber.
7 8 9 10 |
# File 'lib/xml_sanitizer/default_permit_scrubber.rb', line 7 def initialize(tags: []) super @tags = end |
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction.
5 6 7 |
# File 'lib/xml_sanitizer/default_permit_scrubber.rb', line 5 def direction @direction end |
#tags ⇒ Object
Returns the value of attribute tags.
5 6 7 |
# File 'lib/xml_sanitizer/default_permit_scrubber.rb', line 5 def @tags end |
Instance Method Details
#namespace_prefix?(node) ⇒ Boolean
22 23 24 |
# File 'lib/xml_sanitizer/default_permit_scrubber.rb', line 22 def namespace_prefix?(node) !!node&.namespace&.prefix end |
#node_name(node) ⇒ Object
18 19 20 |
# File 'lib/xml_sanitizer/default_permit_scrubber.rb', line 18 def node_name(node) namespace_prefix?(node) ? node_name_with_namespace_prefix(node) : node.name end |
#node_name_with_namespace_prefix(node) ⇒ Object
26 27 28 |
# File 'lib/xml_sanitizer/default_permit_scrubber.rb', line 26 def node_name_with_namespace_prefix(node) "#{node.namespace.prefix}:#{node.name}" end |
#scrub(node) ⇒ Object
12 13 14 15 16 |
# File 'lib/xml_sanitizer/default_permit_scrubber.rb', line 12 def scrub(node) return CONTINUE if skip_node?(node) node.remove unless allowed_node?(node) end |