diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index be5ae2f2823..0a5ad7f7cb1 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -66,7 +66,7 @@ module Email def is_blacklisted? return false if SiteSetting.ignore_by_title.blank? - Regexp.new(SiteSetting.ignore_by_title) =~ @mail.subject + Regexp.new(SiteSetting.ignore_by_title, Regexp::IGNORECASE) =~ @mail.subject end def create_incoming_email diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index 51e655a6b28..6f6e7d50a31 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -568,11 +568,10 @@ describe Email::Receiver do expect { process(:tl4_user) }.to change(Topic, :count) end - it "ignores by title" do + it "ignores by case-insensitive title" do SiteSetting.ignore_by_title = "foo" expect { process(:ignored) }.to_not change(Topic, :count) end - end context "new topic in a category that allows strangers" do diff --git a/spec/components/validators/email_validator_spec.rb b/spec/components/validators/email_validator_spec.rb index 71f6bb746ae..42ff521375d 100644 --- a/spec/components/validators/email_validator_spec.rb +++ b/spec/components/validators/email_validator_spec.rb @@ -21,11 +21,13 @@ describe EmailValidator do it "adds an error when email matches a blocked email" do ScreenedEmail.create!(email: 'sam@sam.com', action_type: ScreenedEmail.actions[:block]) expect(blocks?('sam@sam.com')).to eq(true) + expect(blocks?('SAM@sam.com')).to eq(true) end it "blocks based on email_domains_blacklist" do SiteSetting.email_domains_blacklist = "email.com|mail.com|e-mail.com" expect(blocks?('sam@email.com')).to eq(true) + expect(blocks?('sam@EMAIL.com')).to eq(true) expect(blocks?('sam@bob.email.com')).to eq(true) expect(blocks?('sam@e-mail.com')).to eq(true) expect(blocks?('sam@googlemail.com')).to eq(false) @@ -34,6 +36,7 @@ describe EmailValidator do it "blocks based on email_domains_whitelist" do SiteSetting.email_domains_whitelist = "googlemail.com|email.com" expect(blocks?('sam@email.com')).to eq(false) + expect(blocks?('sam@EMAIL.com')).to eq(false) expect(blocks?('sam@bob.email.com')).to eq(false) expect(blocks?('sam@e-mail.com')).to eq(true) expect(blocks?('sam@googlemail.com')).to eq(false) diff --git a/spec/fixtures/emails/ignored.eml b/spec/fixtures/emails/ignored.eml index 1eafc6a6d23..153a9efb410 100644 --- a/spec/fixtures/emails/ignored.eml +++ b/spec/fixtures/emails/ignored.eml @@ -1,7 +1,7 @@ Return-Path: From: Foo Bar To: category@foo.com -Subject: This is a foo topic +Subject: This is a FoO topic Date: Fri, 15 Jan 2016 00:12:43 +0100 Message-ID: <53@foo.bar.mail> Mime-Version: 1.0