Class: Trenni::Sanitize::Fragment
- Defined in:
- lib/trenni/sanitize/fragment.rb
Constant Summary collapse
- STANDARD_ATTRIBUTES =
Set.new(['class', 'style']).freeze
- ALLOWED_TAGS =
{ 'div' => STANDARD_ATTRIBUTES, 'span' => STANDARD_ATTRIBUTES, 'br' => STANDARD_ATTRIBUTES, 'b' => STANDARD_ATTRIBUTES, 'i' => STANDARD_ATTRIBUTES, 'em' => STANDARD_ATTRIBUTES, 'strong' => STANDARD_ATTRIBUTES, 'ul' => STANDARD_ATTRIBUTES, 'ol' => STANDARD_ATTRIBUTES, 'li' => STANDARD_ATTRIBUTES, 'dl' => STANDARD_ATTRIBUTES, 'dt' => STANDARD_ATTRIBUTES, 'dd' => STANDARD_ATTRIBUTES, 'strike' => STANDARD_ATTRIBUTES, 'h1' => STANDARD_ATTRIBUTES, 'h2' => STANDARD_ATTRIBUTES, 'h3' => STANDARD_ATTRIBUTES, 'h4' => STANDARD_ATTRIBUTES, 'h5' => STANDARD_ATTRIBUTES, 'h6' => STANDARD_ATTRIBUTES, 'p' => STANDARD_ATTRIBUTES, 'img' => STANDARD_ATTRIBUTES + ['src', 'alt', 'width', 'height'], 'image' => STANDARD_ATTRIBUTES, 'a' => STANDARD_ATTRIBUTES + ['href', 'target'] }.freeze
Constants inherited from Filter
Trenni::Sanitize::Filter::ALL, Trenni::Sanitize::Filter::CDATA, Trenni::Sanitize::Filter::COMMENT, Trenni::Sanitize::Filter::CONTENT, Trenni::Sanitize::Filter::DOCTYPE, Trenni::Sanitize::Filter::INSTRUCTION, Trenni::Sanitize::Filter::TAG, Trenni::Sanitize::Filter::TEXT
Instance Attribute Summary
Attributes inherited from Filter
Instance Method Summary collapse
Methods inherited from Filter
#attribute, #cdata, #close_tag, #comment, #initialize, #open_tag_begin, #open_tag_end, parse, #parse!, #parse_begin, #parse_end, #text, #top
Constructor Details
This class inherits a constructor from Trenni::Sanitize::Filter
Instance Method Details
#doctype(string) ⇒ Object
67 68 |
# File 'lib/trenni/sanitize/fragment.rb', line 67 def doctype(string) end |
#filter(node) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/trenni/sanitize/fragment.rb', line 57 def filter(node) if attributes = ALLOWED_TAGS[node.name] node.limit_attributes(attributes) node.accept! else node.skip! end end |
#instruction(string) ⇒ Object
70 71 |
# File 'lib/trenni/sanitize/fragment.rb', line 70 def instruction(string) end |