Fix errors when rendering RSS feeds (#18531)

This commit is contained in:
Eugen Rochko 2022-05-26 23:02:42 +02:00 committed by GitHub
parent 52f4e834f2
commit 0a1992430d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View file

@ -23,7 +23,7 @@ module FormattingHelper
before_html = begin before_html = begin
if status.spoiler_text? if status.spoiler_text?
"<p><strong>#{I18n.t('rss.content_warning', locale: valid_locale_or_nil(status.language))}</strong> #{h(status.spoiler_text)}</p><hr />" "<p><strong>#{I18n.t('rss.content_warning', locale: available_locale_or_nil(status.language) || I18n.default_locale)}</strong> #{h(status.spoiler_text)}</p><hr />"
else else
'' ''
end end

View file

@ -254,4 +254,8 @@ module LanguagesHelper
def valid_locale?(locale) def valid_locale?(locale)
locale.present? && SUPPORTED_LOCALES.key?(locale.to_sym) locale.present? && SUPPORTED_LOCALES.key?(locale.to_sym)
end end
def available_locale_or_nil(locale_name)
locale_name.to_sym if locale_name.present? && I18n.available_locales.include?(locale_name.to_sym)
end
end end

View file

@ -26,4 +26,10 @@ class RSS::MediaContent < RSS::Element
description['type'] = 'plain' description['type'] = 'plain'
end end
end end
def thumbnail(str)
append_element('media:thumbnail') do |thumbnail|
thumbnail['url'] = str
end
end
end end