mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 07:38:06 +08:00
FIX: cleanup aliases in email From and Reply-to fields to prevent Bad sender address syntax errors
This commit is contained in:
@ -56,6 +56,11 @@ describe Email::MessageBuilder do
|
||||
it "returns a Reply-To header with the reply key" do
|
||||
expect(reply_by_email_builder.header_args['Reply-To']).to eq(SiteSetting.title + " <r+#{reply_key}@reply.myforum.com>")
|
||||
end
|
||||
|
||||
it "cleans up the site title" do
|
||||
SiteSetting.stubs(:title).returns(">>>Obnoxious Title: Deal With It<<<")
|
||||
expect(reply_by_email_builder.header_args['Reply-To']).to eq("Obnoxious Title Deal With It <r+#{reply_key}@reply.myforum.com>")
|
||||
end
|
||||
end
|
||||
|
||||
context "With the SiteSetting disabled" do
|
||||
@ -247,6 +252,16 @@ describe Email::MessageBuilder do
|
||||
expect(build_args[:from]).to eq("The Forum <#{SiteSetting.notification_email}>")
|
||||
end
|
||||
|
||||
it "cleans up aliases in the from_alias arg" do
|
||||
builder = Email::MessageBuilder.new(to_address, from_alias: "Finn: the Dog <3", from: finn_email)
|
||||
builder.build_args[:from].should == "Finn the Dog 3 <#{finn_email}>"
|
||||
end
|
||||
|
||||
it "cleans up the email_site_title" do
|
||||
SiteSetting.stubs(:email_site_title).returns("::>>>Best Forum EU: Award Winning<<<")
|
||||
expect(build_args[:from]).to eq("Best Forum EU Award Winning <#{SiteSetting.notification_email}>")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user