mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 06:58:31 +08:00
FEATURE: when blocking emails prefer blocking canonical
Previously we relied entirely on levenshtein_distance_spammer_emails site setting to handle "similar looking" emails. This commit improves the situation by always preferring to block (and check) canonical emails. This means that if: `samevil+test@domain.com` is blocked the system will block `samevil@domain.com` This means that `samevil+2@domain.com` (ad infinitum) will be blocked
This commit is contained in:
@ -26,6 +26,7 @@ describe ScreenedEmail do
|
||||
|
||||
describe '#block' do
|
||||
context 'email is not being blocked' do
|
||||
|
||||
it 'creates a new record with default action of :block' do
|
||||
record = ScreenedEmail.block(email)
|
||||
expect(record).not_to be_new_record
|
||||
@ -57,6 +58,14 @@ describe ScreenedEmail do
|
||||
describe '#should_block?' do
|
||||
subject { ScreenedEmail.should_block?(email) }
|
||||
|
||||
it "automatically blocks via email canonicalization" do
|
||||
SiteSetting.levenshtein_distance_spammer_emails = 0
|
||||
ScreenedEmail.block('bad.acTor+1@gmail.com')
|
||||
ScreenedEmail.block('bad.actOr+2@gmail.com')
|
||||
|
||||
expect(ScreenedEmail.should_block?('b.a.dactor@gmail.com')).to eq(true)
|
||||
end
|
||||
|
||||
it "returns false if a record with the email doesn't exist" do
|
||||
expect(subject).to eq(false)
|
||||
end
|
||||
|
Reference in New Issue
Block a user