mirror of https://github.com/tootsuite/mastodon
Normalize idna domain before account unblock domain (#29530)
parent
a7284690fc
commit
4a6ddbc9c0
|
@ -178,7 +178,7 @@ module Account::Interactions
|
|||
end
|
||||
|
||||
def unblock_domain!(other_domain)
|
||||
block = domain_blocks.find_by(domain: other_domain)
|
||||
block = domain_blocks.find_by(domain: normalized_domain(other_domain))
|
||||
block&.destroy
|
||||
end
|
||||
|
||||
|
@ -300,4 +300,8 @@ module Account::Interactions
|
|||
domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, id),
|
||||
})
|
||||
end
|
||||
|
||||
def normalized_domain(domain)
|
||||
TagManager.instance.normalize_domain(domain)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -250,6 +250,24 @@ describe Account::Interactions do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#block_idna_domain!' do
|
||||
subject do
|
||||
[
|
||||
account.block_domain!(idna_domain),
|
||||
account.block_domain!(punycode_domain),
|
||||
]
|
||||
end
|
||||
|
||||
let(:idna_domain) { '대한민국.한국' }
|
||||
let(:punycode_domain) { 'xn--3e0bs9hfvinn1a.xn--3e0b707e' }
|
||||
|
||||
it 'creates single AccountDomainBlock' do
|
||||
expect do
|
||||
expect(subject).to all(be_a AccountDomainBlock)
|
||||
end.to change { account.domain_blocks.count }.by 1
|
||||
end
|
||||
end
|
||||
|
||||
describe '#unfollow!' do
|
||||
subject { account.unfollow!(target_account) }
|
||||
|
||||
|
@ -345,6 +363,28 @@ describe Account::Interactions do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#unblock_idna_domain!' do
|
||||
subject { account.unblock_domain!(punycode_domain) }
|
||||
|
||||
let(:idna_domain) { '대한민국.한국' }
|
||||
let(:punycode_domain) { 'xn--3e0bs9hfvinn1a.xn--3e0b707e' }
|
||||
|
||||
context 'when blocking the domain' do
|
||||
it 'returns destroyed AccountDomainBlock' do
|
||||
account_domain_block = Fabricate(:account_domain_block, domain: idna_domain)
|
||||
account.domain_blocks << account_domain_block
|
||||
expect(subject).to be_a AccountDomainBlock
|
||||
expect(subject).to be_destroyed
|
||||
end
|
||||
end
|
||||
|
||||
context 'when unblocking idna domain' do
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#following?' do
|
||||
subject { account.following?(target_account) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue