Skip to content

Commit

Permalink
Fix link verifications when page size exceeds 1MB (mastodon#29358)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Feb 22, 2024
1 parent b0822ae commit f254140
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/services/verify_link_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def call(field)

def perform_request!
@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

Expand Down
13 changes: 7 additions & 6 deletions spec/services/verify_link_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,25 @@
"
<!doctype html>
<body>
<a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}\"
<a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}\">
"
end

it 'marks the field as not verified' do
expect(field.verified?).to be false
it 'marks the field as verified' do
expect(field.verified?).to be true
end
end

context 'when a link back might be truncated' do
context 'when a link tag might be truncated' do
let(:html) do
"
<!doctype html>
<body>
<a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}"
<a rel=\"me\" href=\"#{ActivityPub::TagManager.instance.url_for(account)}\"
"
end

it 'does not mark the field as verified' do
it 'marks the field as not verified' do
expect(field.verified?).to be false
end
end
Expand Down

0 comments on commit f254140

Please sign in to comment.