Fix link verifications when page size exceeds 1MB (#29358)

pull/29365/head
Claire 1 year ago committed by GitHub
parent a9496882fc
commit 5152dd869e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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

@ -80,24 +80,25 @@ RSpec.describe VerifyLinkService, type: :service do
" "
<!doctype html> <!doctype html>
<body> <body>
<a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}\" <a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}\">
" "
end end
it 'marks the field as not verified' do it 'marks the field as verified' do
expect(field.verified?).to be false expect(field.verified?).to be true
end end
end end
context 'when a link back might be truncated' do context 'when a link tag might be truncated' do
let(:html) do let(:html) do
" "
<!doctype html> <!doctype html>
<body> <body>
<a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}" <a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}\"
"
end end
it 'does not mark the field as verified' do it 'marks the field as not verified' do
expect(field.verified?).to be false expect(field.verified?).to be false
end end
end end

Loading…
Cancel
Save