diff --git a/app/models/metadata_template.rb b/app/models/metadata_template.rb index 45e6a4d0..e40bd891 100644 --- a/app/models/metadata_template.rb +++ b/app/models/metadata_template.rb @@ -1,5 +1,11 @@ # frozen_string_literal: true +module MetadataTemplateConstants + ALLOWED_ATTRIBUTES = %w[style href src alt controls data-align data-multimedia data-multimedia-inner id name].freeze + ALLOWED_TAGS = %w[strong em del u mark p h1 h2 h3 h4 h5 h6 ul ol li img iframe audio video div figure blockquote + figcaption a sub sup small].freeze +end + # Representa la plantilla de un campo en los metadatos del artĂ­culo # # TODO: Validar el tipo de valor pasado a value= segĂșn el :type @@ -8,6 +14,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, :value, :help, :required, :errors, :post, :layout, keyword_init: true) do + include MetadataTemplateConstants include Metadata::FrontMatterConcern # @return [String] @@ -222,8 +229,8 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, sanitizer .sanitize(string.tr("\r", '').unicode_normalize, - tags: allowed_tags, - attributes: allowed_attributes) + tags: ALLOWED_TAGS, + attributes: ALLOWED_ATTRIBUTES) .strip .html_safe end @@ -233,16 +240,6 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, @sanitizer ||= Rails::Html::Sanitizer.safe_list_sanitizer.new end - def allowed_attributes - @allowed_attributes ||= %w[style href src alt controls data-align data-multimedia data-multimedia-inner id - name].freeze - end - - def allowed_tags - @allowed_tags ||= %w[strong em del u mark p h1 h2 h3 h4 h5 h6 ul ol li img iframe audio video div figure blockquote - figcaption a sub sup small].freeze - end - # Decifra el valor # # @todo Agregar el error de decifrado en self.errors