FEATURE: Obfuscate emails on invite show page (#12433)

The email should not be ever displayed in clear text, except the case
when the user authenticates using another service.
This commit is contained in:
Dan Ungureanu
2021-03-18 19:09:23 +02:00
committed by GitHub
parent da1e37d2ce
commit 033d6b6437
3 changed files with 58 additions and 1 deletions

View File

@ -44,4 +44,25 @@ describe Email do
end
describe "obfuscate" do
it 'correctly obfuscates emails' do
expect(Email.obfuscate('a@b.com')).to eq('*@*.com')
expect(Email.obfuscate('test@test.co.uk')).to eq('t***@t***.**.uk')
expect(Email.obfuscate('simple@example.com')).to eq('s****e@e*****e.com')
expect(Email.obfuscate('very.common@example.com')).to eq('v*********n@e*****e.com')
expect(Email.obfuscate('disposable.style.email.with+symbol@example.com')).to eq('d********************************l@e*****e.com')
expect(Email.obfuscate('other.email-with-hyphen@example.com')).to eq('o*********************n@e*****e.com')
expect(Email.obfuscate('fully-qualified-domain@example.com')).to eq('f********************n@e*****e.com')
expect(Email.obfuscate('user.name+tag+sorting@example.com')).to eq('u*******************g@e*****e.com')
expect(Email.obfuscate('x@example.com')).to eq('*@e*****e.com')
expect(Email.obfuscate('example-indeed@strange-example.com')).to eq('e************d@s*************e.com')
expect(Email.obfuscate('example@s.example')).to eq('e*****e@*.example')
expect(Email.obfuscate('mailhost!username@example.org')).to eq('m***************e@e*****e.org')
expect(Email.obfuscate('user%example.com@example.org')).to eq('u**************m@e*****e.org')
expect(Email.obfuscate('user-@example.org')).to eq('u***-@e*****e.org')
end
end
end