mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 13:04:32 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user