mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
handle nil product descriptions
This commit is contained in:
@@ -21,7 +21,7 @@ class Api::ProductSerializer < ActiveModel::Serializer
|
||||
|
||||
# return a sanitized html description
|
||||
def description_html
|
||||
sanitizer.sanitize_content(object.description).html_safe
|
||||
sanitizer.sanitize_content(object.description)&.html_safe
|
||||
end
|
||||
|
||||
def properties_with_values
|
||||
|
||||
@@ -14,15 +14,19 @@ class ContentSanitizer
|
||||
}.freeze
|
||||
|
||||
def strip_content(content)
|
||||
return unless content.present?
|
||||
|
||||
content = strip_tags(content.to_s.strip)
|
||||
|
||||
filter_characters(content) if content.present?
|
||||
filter_characters(content)
|
||||
end
|
||||
|
||||
def sanitize_content(content)
|
||||
return unless content.present?
|
||||
|
||||
content = sanitize(content.to_s, tags: ALLOWED_TAGS, attributes: ALLOWED_ATTRIBUTES)
|
||||
|
||||
filter_characters(content) if content.present?
|
||||
filter_characters(content)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user