mirror of
https://github.com/mastodon/mastodon.git
synced 2026-09-12 20:06:18 -05:00
Minor updates to support showing case insitive verified domains
This commit is contained in:
@@ -44,6 +44,6 @@ class VerifyLinkService < BaseService
|
||||
res.headers['Location']
|
||||
end
|
||||
|
||||
redirect_to_url == @link_back
|
||||
redirect_to_url&.downcase == @link_back.downcase
|
||||
end
|
||||
end
|
||||
|
||||
@@ -211,4 +211,68 @@ RSpec.describe VerifyLinkService do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when given a local account with an uppercase URL' do
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
let(:field) { Account::Field.new(account, 'name' => 'Website', 'value' => 'http://EXAMPLE.COM/Path') }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'http://EXAMPLE.COM/Path').to_return(status: 200, body: html)
|
||||
subject.call(field)
|
||||
end
|
||||
|
||||
context 'when a link contains an <a> back' do
|
||||
let(:html) do
|
||||
<<~HTML
|
||||
<!doctype html>
|
||||
<body>
|
||||
<a href="#{ActivityPub::TagManager.instance.url_for(account)}" rel="me">Follow me on Mastodon</a>
|
||||
</body>
|
||||
HTML
|
||||
end
|
||||
|
||||
it 'marks the field as verified' do
|
||||
expect(field.verified?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a link contains an uppercase <a> back' do
|
||||
let(:html) do
|
||||
<<~HTML
|
||||
<!doctype html>
|
||||
<body>
|
||||
<a href="#{ActivityPub::TagManager.instance.url_for(account).upcase}" rel="me">Follow me on Mastodon</a>
|
||||
</body>
|
||||
HTML
|
||||
end
|
||||
|
||||
it 'marks the field as verified' do
|
||||
expect(field.verified?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when link goes through a redirect with different case' do
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
let(:field) { Account::Field.new(account, 'name' => 'Website', 'value' => 'http://example.com') }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'http://example.com').to_return(status: 200, body: html)
|
||||
stub_request(:head, 'https://redirect.me/abc').to_return(status: 301, headers: { 'Location' => ActivityPub::TagManager.instance.url_for(account).upcase })
|
||||
subject.call(field)
|
||||
end
|
||||
|
||||
let(:html) do
|
||||
<<~HTML
|
||||
<!doctype html>
|
||||
<head>
|
||||
<link type="text/html" href="https://redirect.me/abc" rel="me" />
|
||||
</head>
|
||||
HTML
|
||||
end
|
||||
|
||||
it 'marks the field as verified' do
|
||||
expect(field.verified?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user