Module: MixedContentValidator
- Defined in:
- common/mixed_content_validator.rb
Overview
Validates inline EAD markup is well formed.
Constant Summary collapse
- DISALLOWED_TAGS =
%w[ script style iframe object embed applet meta link base form input button select textarea option optgroup label fieldset ].freeze
Class Method Summary collapse
Class Method Details
.error_for_inline_ead(content) ⇒ Object
11 12 13 14 15 16 |
# File 'common/mixed_content_validator.rb', line 11 def self.error_for_inline_ead(content) return 'mixed_content_disallowed_tag' unless (content) return nil if valid_inline_ead?(content) 'mixed_content_invalid_inline_ead' end |
.valid_inline_ead?(content) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'common/mixed_content_validator.rb', line 18 def self.valid_inline_ead?(content) return true if content.nil? || content.strip.empty? return true unless content.include?('<') # Inspect each opening tag and ensure attribute assignments are properly quoted # Regex: match opening tags only (exclude comments <!>, processing <?>, and closing </>); # capture tag name (group 1) and raw attributes text (group 2) attributes_ok = content.scan(/<(?!!|\?|\/)([A-Za-z][A-Za-z0-9:_-]*)([^>]*)>/).all? do |tag, attrs| attributes_are_well_quoted?(attrs) end attributes_ok && (content) end |