FIX: Set the lang/xml:lang html attrs in emails (#10218)

In some rare cases emails are incorrectly sent out with lang placeholders in body (`xml:lang="%{html_lang}"`)
This commit is contained in:
Jarek Radosz 2020-07-13 16:39:40 +02:00 committed by GitHub
parent 8e2f57a498
commit a96ff82e53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -26,7 +26,10 @@ module EmailHelper
end end
def email_html_template def email_html_template
EmailStyle.new.html.sub('%{email_content}', capture { yield }).html_safe EmailStyle.new.html
.sub('%{email_content}', capture { yield })
.gsub('%{html_lang}', html_lang)
.html_safe
end end
protected protected

View File

@ -236,6 +236,14 @@ describe UserNotifications do
expect(html).to include(topic_url) expect(html).to include(topic_url)
expect(text).to include(topic_url) expect(text).to include(topic_url)
end end
it "applies lang/xml:lang html attributes" do
SiteSetting.default_locale = "pl_PL"
html = subject.html_part.to_s
expect(html).to match(' lang="pl-PL"')
expect(html).to match(' xml:lang="pl-PL"')
end
end end
end end