Skip to content

Commit 499b0a8

Browse files
valeraukohiyuki2578
authored andcommitted
Ignore JSON-LD profile in mime type comparison (mastodon#9179)
Ignore JSON-LD profile in mime type comparison
1 parent 5fb65b1 commit 499b0a8

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

app/services/fetch_atom_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def process(url, terminal = false)
2929

3030
def perform_request(&block)
3131
accept = 'text/html'
32-
accept = 'application/activity+json, application/ld+json, application/atom+xml, ' + accept unless @unsupported_activity
32+
accept = 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams", application/atom+xml, ' + accept unless @unsupported_activity
3333

3434
Request.new(:get, @url).add_headers('Accept' => accept).perform(&block)
3535
end
@@ -39,7 +39,7 @@ def process_response(response, terminal = false)
3939

4040
if response.mime_type == 'application/atom+xml'
4141
[@url, { prefetched_body: response.body_with_limit }, :ostatus]
42-
elsif ['application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'].include?(response.mime_type)
42+
elsif ['application/activity+json', 'application/ld+json'].include?(response.mime_type)
4343
body = response.body_with_limit
4444
json = body_to_json(body)
4545
if supported_context?(json) && equals_or_includes_any?(json['type'], ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES) && json['inbox'].present?

spec/services/fetch_atom_service_spec.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,15 @@
6060
it { is_expected.to eq [url, { :prefetched_body => "" }, :ostatus] }
6161
end
6262

63-
context 'content_type is json' do
64-
let(:content_type) { 'application/activity+json' }
63+
context 'content_type is activity+json' do
64+
let(:content_type) { 'application/activity+json; charset=utf-8' }
65+
let(:body) { json }
66+
67+
it { is_expected.to eq [1, { prefetched_body: body, id: true }, :activitypub] }
68+
end
69+
70+
context 'content_type is ld+json with profile' do
71+
let(:content_type) { 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }
6572
let(:body) { json }
6673

6774
it { is_expected.to eq [1, { prefetched_body: body, id: true }, :activitypub] }

0 commit comments

Comments
 (0)