mirror of
https://github.com/kikobar/mastodon.git
synced 2024-11-16 12:12:14 +00:00
Fix link verifications when page size exceeds 1MB (#29361)
This commit is contained in:
parent
328a9b8157
commit
9a7802655f
|
@ -19,7 +19,7 @@ class VerifyLinkService < BaseService
|
||||||
|
|
||||||
def perform_request!
|
def perform_request!
|
||||||
@body = Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res|
|
@body = Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res|
|
||||||
res.code == 200 ? res.body_with_limit : nil
|
res.code == 200 ? res.truncated_body : nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,20 @@ RSpec.describe VerifyLinkService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a document is truncated but the link back is valid' do
|
context 'when a document is truncated but the link back is valid' do
|
||||||
|
let(:html) do
|
||||||
|
"
|
||||||
|
<!doctype html>
|
||||||
|
<body>
|
||||||
|
<a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}\">
|
||||||
|
"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'marks the field as verified' do
|
||||||
|
expect(field.verified?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when a link tag might be truncated' do
|
||||||
let(:html) do
|
let(:html) do
|
||||||
"
|
"
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
|
@ -89,19 +103,6 @@ RSpec.describe VerifyLinkService, type: :service do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a link back might be truncated' do
|
|
||||||
let(:html) do
|
|
||||||
"
|
|
||||||
<!doctype html>
|
|
||||||
<body>
|
|
||||||
<a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}"
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not mark the field as verified' do
|
|
||||||
expect(field.verified?).to be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when a link does not contain a link back' do
|
context 'when a link does not contain a link back' do
|
||||||
let(:html) { '' }
|
let(:html) { '' }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue