diff --git a/app/lib/html_aware_formatter.rb b/app/lib/html_aware_formatter.rb index 64edba09b5..303e4a15e7 100644 --- a/app/lib/html_aware_formatter.rb +++ b/app/lib/html_aware_formatter.rb @@ -15,8 +15,6 @@ class HtmlAwareFormatter end def to_s - return ''.html_safe if text.blank? - if local? linkify else @@ -29,6 +27,8 @@ class HtmlAwareFormatter private def reformat + return ''.html_safe if text.blank? + Sanitize.fragment(text, Sanitize::Config::MASTODON_STRICT) end diff --git a/spec/requests/api/v1/statuses_spec.rb b/spec/requests/api/v1/statuses_spec.rb index 5cfd4eaa48..5db9889e2d 100644 --- a/spec/requests/api/v1/statuses_spec.rb +++ b/spec/requests/api/v1/statuses_spec.rb @@ -344,7 +344,7 @@ RSpec.describe '/api/v1/statuses' do .to start_with('application/json') expect(response.parsed_body[:quote]).to be_present expect(response.parsed_body[:spoiler_text]).to eq 'this is a CW' - expect(response.parsed_body[:content]).to eq '' + expect(response.parsed_body[:content]).to match(/RE: /) expect(response.headers['X-RateLimit-Limit']).to eq RateLimiter::FAMILIES[:statuses][:limit].to_s expect(response.headers['X-RateLimit-Remaining']).to eq (RateLimiter::FAMILIES[:statuses][:limit] - 1).to_s end diff --git a/spec/serializers/rest/status_serializer_spec.rb b/spec/serializers/rest/status_serializer_spec.rb index be1b4bcae4..510328c7fb 100644 --- a/spec/serializers/rest/status_serializer_spec.rb +++ b/spec/serializers/rest/status_serializer_spec.rb @@ -19,6 +19,25 @@ RSpec.describe REST::StatusSerializer do let(:bob) { Fabricate(:account, username: 'bob', domain: 'other.com') } let(:status) { Fabricate(:status, account: alice) } + context 'with a local status' do + context 'with a quote and a CW but no contents' do + let(:quoted_status) { Fabricate(:status, account: alice) } + let(:status) { Fabricate.build(:status, account: alice, text: '', spoiler_text: 'this is a CW') } + + before do + Fabricate(:quote, status: status, quoted_status: quoted_status, state: :accepted) + end + + it 'renders the status with a CW and fallback link' do + expect(subject) + .to include( + 'content' => /RE: 'this is a CW' + ) + end + end + end + context 'with a remote status' do let(:status) { Fabricate(:status, account: bob) }